Entry
How can I get the part of a request after the question mark?
How can I get the query part of a GET request?
Feb 4th, 2006 06:51
Andrew Mather, Nathan Wallace, Onno Benschop, George Brown, John R. Levine
PHP will automatically parse the URL request and set the variables
specified. [*** NOTE: NOT IN PHP VERSIONS AFTER 4.2.0 *** see below]
http://whatever/blah.phtml?foo=1&bar=2
// $foo is 1
// $bar is 2
Sometimes though you may be interested in using the actual value of the
variables string. This is available as:
// $QUERY_STRING is foo=1&bar=2
[see also eg: echo($_SERVER['QUERY_STRING']); ]
*** NOTE: ARGUMENTS ARE NO LONGER AUTOMATICALLY AVAILABLE as of PHP 4.2 ***
See: http://uk2.php.net/manual/en/language.variables.external.php
KEY SECTION IS THIS: -- Note PHP directive register_globals --
<?php
// Available since PHP 4.1.0
echo $_POST['username'];
echo $_REQUEST['username'];
import_request_variables('p', 'p_');
echo $p_username;
// Available since PHP 3. As of PHP 5.0.0, these long predefined
// variables can be disabled with the register_long_arrays directive.
echo $HTTP_POST_VARS['username'];
// Available if the PHP directive register_globals = on. As of
// PHP 4.2.0 the default value of register_globals = off.
// Using/relying on this method is not preferred.
echo $username;
?>