Entry
Why do I get the error: undefined variable: QUERY_STRING for predefined variable $QUERY_STRING ?
Feb 1st, 2002 21:33
Philip Olson, Gerald Clerc, Onno Benschop,
"undefined variable" is a PHP error of level E_NOTICE. QUERY_STRING is
a Predefined Variable that's available in PHP.
If the register_globals PHP directive (in php.ini) is off, the variable
$QUERY_STRING will not exist (undefined). If register_globals is on,
$QUERY_STRING will exist*. For this reason, it is preferred to NOT
use $QUERY_STRING. More reliable ways on calling QUERY_STRING are:
getenv('QUERY_STRING') // see: http://www.php.net/getenv
$_SERVER['QUERY_STRING'] // $_SERVER available as of PHP 4.1.0
$HTTP_SERVER_VARS['QUERY_STRING']
For information purposes, QUERY_STRING is generated by the web server
(such as Apache) and is defined as:
QUERY_STRING
The information which follows the ? in the URL which referenced
this script. This is the query information. It should not be
decoded in any fashion. This variable should always be set when
there is query information, regardless of command line decoding.
http://hoohoo.ncsa.uiuc.edu/cgi/env.html
* Before php version 4.2.0, it was common to have register_globals on
which made all predefined variables register, like, $QUERY_STRING. See
also directive variables_order and:
http://www.php.net/manual/en/language.variables.predefined.php