Environment variable: $ _ ENV
Note: PHP 4.1.0 and later versions are used. 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 them are determined by the system running PHP. A complete list is impossible. 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. This only means that it is valid in all scripts. You do not need to use global $ _ ENV; to access a function or method, 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. For more information, see the security section using Register Globals. These independent global variables are not automatic global variables.
View instances
<? Php Tutorial
Echo 'My username is '. $ _ ENV ["USER"].'! ';
?>
Assume that "bjori" runs this script.
The output of the preceding routine is similar:
My username is bjori!
Instance 2
<? Php
If (isset ($ _ ENV ["HOSTNAME"])
$ MachineName = $ _ ENV ["HOSTNAME"];
Else if (isset ($ _ ENV ["COMPUTERNAME"])
$ MachineName = $ _ ENV ["COMPUTERNAME"];
Else $ MachineName = "";
?>
To the global namespace of PHP. Many are provided by shells that support PHP running, and different systems may run different types of shells, so there is no definite list. Please refer to your Shell document to obtain the list of defined environment variables.
Other environment variables include CGI variables, regardless of whether PHP runs 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.