Share an example of using the PHP function getenv. The getenv function is mainly used to obtain the value of an environment variable. Common PHP probe programs use the getenv function.
getenv(PHP 4, PHP 5)
// getenv — Get the value of an environment variable
Function description: www.jbxue.com
string getenv ( string $varname )
// Get the value of an environment variable.
// Using phpinfo() you can see a list of all environment variables.
Parameter description:
$varname variable name.
Function return value:
// Returns the value of the environment variable varname. If the environment variable varname does not exist, it returns FALSE.
Function application example:
<?<span>php </span><span>//</span><span> getenv() 使用示例</span> <span>$ip</span> = <span>getenv</span>('REMOTE_ADDR'<span>); </span><span>//</span><span> 或简单仅使用全局变量($_SERVER 或 $_ENV)</span> <span>$ip</span> = <span>$_SERVER</span>['REMOTE_ADDR'<span>]; </span>?>
You can see the configuration information of the entire PHP environment through phpinfo, so what should you do if you want to get one of the variable information?
Get the following information:
php code:
<span>echo</span> <span>getenv</span>('userprofile');<span>//</span><span> C:\Windows\system32\config\systemprofile</span>