English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

For example, if you have a url:

http:// www.mypage.com/ showinfo.php ?id=22

what do the values to the right of the question mark mean (in this case, id=22)?

I believe that it's a way to pass variable information via hyperlinks-- am I correct? And once you get to the showinfo.php page in the example, what code would you need in order to access id's value?

(Specific code examples, or a reference to a tutorial on the subject, would be appreciated. I don't even know what this passing-values-with-hyperlinks thing is called, so I can't look up tuotorials on my own!)

2006-11-09 03:23:05 · 3 answers · asked by Anonymous in Computers & Internet Programming & Design

3 answers

These are name-value pairs. In your example, the script receives a variable named 'id' with a value of 22.

Variables passed this way (by the way, it's called the GET method; there is also a slightly more complicated POST method) are accessible through a superglobal array called $_GET. In your example, you can write:

echo $_GET['id'];

which should output 22.

"Superglobal" means that $_GET (and its siblings, $_POST, $_REQUEST, $_SERVER, $_ENV, $_SESSION and $_COOKIE) is accessible from anywhere (including code inside functions and class definitions).

2006-11-09 05:59:00 · answer #1 · answered by NC 7 · 0 0

You need to look up SuperGlobals in the php manual. Variables stored in the url are stored in $_GET in php. There is also $_POST for transfering larger variables not in the URL. These correspond with get and post actions in webpage forms.

I suggest you also find a tutorial about webpage forms and specifically look at the sections dealing with POST and GET options.

2006-11-09 03:36:37 · answer #2 · answered by Anonymous · 0 0

to get the url encode: if i undersand you wisely, for question a million use this $_SERVER['PHP_SELF']; this might get you to recreation.own residing house page basically without the question string. for question 2 //first get the url utilising $_SERVER['REQUEST_URI'] to get the entire url $url = $_SERVER['REQUEST_URI']; //then explode it into array utilising "?" as separator to get basically the question string $url_array=explode("?",$url); print $url_array[a million]; // it somewhat is the question string code=12 //or you could explode utilising "=" as separator to get basically the value 12 $url_array=explode("=",$url); print $url_array[a million]; // this might return value 12

2016-10-21 13:06:02 · answer #3 · answered by ? 4 · 0 0

fedest.com, questions and answers