getenv

(PHP 3, PHP 4, PHP 5)

getenv -- Gets the value of an environment variable

说明

string getenv ( string varname )

Gets the value of an environment variable.

You can see a list of all the environmental variables by using phpinfo(). You can find out what many of them mean by taking a look at the CGI specification, specifically the page on environmental variables.

参数

varname

The variable name.

返回值

Returns the value of the environment variable varname, or FALSE on an error.

范例

例 1. getenv() Example

<?php
// Example use of getenv()
$ip = getenv('REMOTE_ADDR');

// Or simply use a Superglobal ($_SERVER or $_ENV)
$ip = $_SERVER['REMOTE_ADDR'];
?>

参见

putenv()
apache_getenv()
Superglobals