Php $ _ ENV environment variable description

Source: Internet
Author: User
Tags php tutorial versions

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.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.