Entry
How to make that $var get read from the url?ex: $var = name -> sample.php?name=John ->output is John
exapmle: http://foo.com/sample.php?name=John -> It writes out: Hello John
Jun 23rd, 2002 17:36
Philip Olson, Ben Udall, David Valentine,
There are many ways to access this GET information that lives in the URL
(QUERY_STRING), ways such as:
// Works since PHP 3 (forever)
print $HTTP_GET_VARS['name'];
// Works since PHP 4.1.0 (new superglobals introduced)
print $_GET['name']
// Works if the PHP directive register_globals is ON. This
// is OFF by default as of PHP 4.2.0 and PHP users are
// encouraged to not rely on this behavior.
print $name;
// Works since PHP 4.1.0 (this function introduced)
import_request_variables('gpc', 'r_');
print $r_name;
As you can see, many ways exist. For related information, see:
* http://www.php.net/manual/en/language.variables.predefined.php
* http://www.php.net/manual/en/language.variables.external.php