faqts : Computers : Programming : Languages : PHP : kms : General : Variables

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

17 of 17 people (100%) answered Yes
Recently 10 of 10 people (100%) answered Yes

Entry

What is the correct syntax for passing more than 1 variable in a URL? And does the script need to do anything to parse out the variables?

Mar 23rd, 2001 20:09
Ben Udall, Charles Johnson,


The syntax can be loosely defined as such:
http://domain.com/script.php?name1=value1&name2=value2&name3=value3
After the initial question mark (?), variables are passed as name=value 
pairs seperated by the ampersand (&).  Also, the values need to be 
urlencoded.
Here's an example, if you were constructing such a url:
$bob  = "Hello ";
$fred = "world!";
$url = "http://domain.com/script.php?".
       "bob=".urlencode($bob) . "&fred=".urlencode($fred);
$url would now look like this:
http://domain.com/script.php?bob=Hello+&fred=world%21
As for your second question, the script doesn't need to do anything to 
parse out the vars.  PHP handles all of that behind the scenes.