Getenv (PHP 4, PHP 5)
Copy Code code as follows:
Getenv-gets the value of an environment variable
Function Description:
String getenv (String $varname)
Copy Code code as follows:
Gets the value of an environment variable.
Using Phpinfo () you can see a list of all the environment variables.
Parameter description:
Copy Code code as follows:
function return value:
Copy Code code as follows:
Returns the value of the environment variable varname, or FALSE if the environment variable varname does not exist.
Function Application instance:
Copy Code code as follows:
<?php
Getenv () using the example
$ip = getenv (' remote_addr ');
Or simply use global variables ($_server or $_env)
$ip = $_server[' remote_addr '];
?>
You can see the configuration information for the entire PHP environment through phpinfo, so what do you want to get one of the variable information?
Below the actual display, for example I want to get the following information:
So, the source code of PHP is:
Copy Code code as follows:
echo getenv (' userprofile ');//C:\Windows\system32\config\systemprofile
Easy, huh? Hey!