|
PHP provides a large number of predefined variables to any script
which it runs. Many of these variables, however, cannot be fully
documented as they are dependent upon which server is running, the
version and setup of the server, and other factors. Some of these
variables will not be available when PHP is run on the command
line. For a listing of these variables, please see the section
Predefined variables.
Varovßnφ |
In PHP 4.2.0 and later, the default set of predefined variables
which are available in the global scope has changed. Individual
input and server variables are by default no
longer placed directly into the global scope; rather, they are
placed into the following superglobal
arrays.
You can still force the old behaviour by setting register_globals to 'On' in
your php.ini file.
For more information and background on this change, please see
the PHP 4.1.0 Release
Announcement.
|
From version 4.1.0 onward, PHP provides a set of predefined arrays
containing variables from the web server (if applicable), the
environment, and user input. These new arrays are rather special
in that they are automatically global--i.e., automatically
available in every scope. For this reason, they are often known as
'autoglobals' or 'superglobals'. (There is no mechanism in PHP for
user-defined superglobals.) The superglobals are listed below;
however, for a listing of their contents and further discussion on
PHP predefined variables and their natures, please see the section
Predefined variables.
PHP Superglobals - $GLOBALS
Contains a reference to every variable which is currently
available within the global scope of the script. The keys of
this array are the names of the global variables.
- $_SERVER
Variables set by the web server or otherwise directly related
to the execution environment of the current script. Analogous
to the old $HTTP_SERVER_VARS array (which is
still available, but deprecated).
- $_GET
Variables provided to the script via HTTP GET. Analogous to the
old $HTTP_GET_VARS array (which is still
available, but deprecated).
- $_POST
Variables provided to the script via HTTP POST. Analogous to the
old $HTTP_POST_VARS array (which is still
available, but deprecated).
- $_COOKIE
Variables provided to the script via HTTP cookies. Analogous to
the old $HTTP_COOKIE_VARS array (which is
still available, but deprecated).
- $_FILES
Variables provided to the script via HTTP post file
uploads. Analogous to the old
$HTTP_POST_FILES array (which is still
available, but deprecated). See POST method
uploads for more information.
- $_ENV
Variables provided to the script via the environment. Analogous
to the old $HTTP_ENV_VARS array (which is
still available, but deprecated).
- $_REQUEST
Variables provided to the script via any user input mechanism,
and which therefore cannot be trusted. Note: when running on
the command line, this will not include
the argv and argc
entries; these are present in the $_SERVER
array. The presence and order of variable inclusion in this
array is defined according to the variables_order
configuration directive. This array has no direct analogue in
versions of PHP prior to 4.1.0.
- $_SESSION
Variables which are currently registered to a script's
session. Analogous to the old
$HTTP_SESSION_VARS array (which is still
available, but deprecated). See the Session handling functions section
for more information.
| |