Getenv (PHP 4, PHP 5)
Copy codeThe Code is as follows: // getenv-obtains the value of an environment variable.
Function Description:
String getenv (string $ varname)
Copy codeThe Code is as follows: // obtain the value of an environment variable.
// Use phpinfo () to view the list of all environment variables.
Parameter description:
Copy codeThe Code is as follows: $ varname variable name.
Function return value:
Copy codeThe Code is as follows: // return the value of the environment variable varname. If the environment variable varname does not exist, FALSE is returned.
Function Application Example:
Copy codeThe Code is as follows: <? Php
// Getenv () Example
$ Ip = getenv ('remote _ ADDR ');
// Or simply use only global variables ($ _ SERVER or $ _ ENV)
$ Ip = $ _ SERVER ['remote _ ADDR '];
?>
You can see the configuration information of the entire PHP environment through phpinfo. What if you want to get the information of one of the variables?
The following is an example of how to obtain the following information:
The PHP source code is:
Copy codeThe Code is as follows: echo getenv ('userprofile '); // C: \ Windows \ system32 \ config \ systemprofile
Is it Easy? Hey ~