PHP provides a large number of predefined variables. Because many variables depend on the version and settings of the running server, and other factors, there is no detailed description document. Some predefined variables do not take effect when PHP is run as a command line. PHP provides a large number of predefined variables. Because many variables depend on the version and settings of the running server, and other factors, there is no detailed description document. Some predefined variables do not take effect when PHP is run as a command line.
Warning
In PHP 4.2.0 and later versions, the default value of the PHP command register_globals is off. This is a major change in PHP. Setting the value of register_globals to off affects the validity of the predefined variable set within the global range. For example, to obtain the DOCUMENT_ROOT value, you must use $ _ SERVER ['document _ root'] instead of $ DOCUMENT_ROOT, as shown in the following figure, use $ _ GET ['id'] instead of $ id from URL http://www.example.com/test.php? In id = 3, get the id value, or use $ _ ENV ['home'] instead of $ HOME to get the value of the environment variable HOME.
If there are available PHP pre-defined variables, it is best to use them, such as ultra-Global arrays.
Starting from PHP 4.1.0, PHP provides an additional set of pre-defined arrays that contain data from the web server (if available), runtime environment, and user input. These arrays are very special and they take effect globally, for example, automatically within any range. Therefore, it is usually called autoglobals or superglobals ). (PHP does not have a mechanism for customizing global variables .) Hyperglobal variables are listed below. For more information about them, PHP predefined variables, and their nature, see predefine variables. In addition, you will also notice that the old pre-defined array ($ HTTP _ * _ VARS) still exists. From PHP 5.0.0, you can use register_long_arrays to disable long PHP pre-defined variable arrays.
Note: variable
Super global variables cannot be used as variable variables in functions or class methods.
Note:
Although the hyper-global variables and HTTP _ * _ VARS both exist, they are not the same variable. Therefore, changing one value does not affect the other.
If some variables in variables_order are not set, their corresponding PHP pre-defined arrays are also empty.