Environment variable: $ _ ENV note: it is used in PHP410 and later versions. for earlier versions, $ HTTP_ENV_VARS is used. when the parser is running, these variables change from environment variables to PHP global variable namespace, many of which are systems run by PHP.
Environment variable: $ _ ENV note: it is used in PHP 4.1.0 and later versions. in earlier versions, $ HTTP_ENV_VARS is used. when the parser is running, these variables change from environment variables to PHP global variable namespace, many of which are determined by the system running PHP, and the complete list is impossible, check the system documentation to determine its specific environment variables.
Environment variable: $ _ ENV
Note: For PHP 4.1.0 and later versions, $ HTTP_ENV_VARS is used for earlier versions.
When the parser is running, these variables change from environment variables to PHP global variable namespace, many of which are determined by the system running PHP, the complete list is not possible. Please check the system documentation to determine its specific environment variables.
Other environment variables (including CGI variables), whether PHP is run as a server module or as a CGI, are listed here.
This is a "superglobal", or it can be described as an automatic global variable, which means it is valid in all scripts and does not need to use global $ _ ENV in functions or methods; to access it, just like using $ HTTP_ENV_VARS.
$ HTTP_ENV_VARS contains the same information, but it is not an automatic global variable (note: $ HTTP_ENV_VARS and $ _ ENV are different variables, and PHP processes them differently ).
If the register_globals command is set, these variables are also available in all scripts, that is, the $ _ ENV and $ HTTP_ENV_VARS arrays are separated, refer to the security section to use Register Globals. these independent global variables are not automatic global variables.
The instance code is as follows:
-
- Echo 'My username is '. $ _ ENV ["USER"].'! ';
- ?>
Assume that "bjori" runs this script. the output of the above routine is similar to: My username is bjori!
The code for instance 2 is as follows:
-
- If (isset ($ _ ENV ["HOSTNAME"])
- $ MachineName = $ _ ENV ["HOSTNAME"];
- Else if (isset ($ _ ENV ["COMPUTERNAME"])
- $ MachineName = $ _ ENV ["COMPUTERNAME"];
- Else $ MachineName = "";
- ?>
The runtime environment is imported into the global namespace of PHP, many of which are provided by the Shell that supports PHP running, and different systems may run different types of shells, therefore, it is impossible to have a definite list. Please check your Shell document to obtain the list of defined environment variables.
Other environment variables include CGI variables, regardless of whether PHP is run as a server module or CGI processor.
$ HTTP_ENV_VARS contains the same information, but it is not a super global variable. (note that $ HTTP_ENV_VARS and $ _ ENV are different variables. PHP processes them differently.