8.21.1 Problem
8.21.2 Solution
Read the value from the $_ENV superglobal array:
$name = $_ENV['USER'];
8.21.3 Discussion
Environment variables are named values associated with a
process. For instance, in Unix, you can check the value
of $_ENV['HOME'] to find the home directory of a user:
print $_ENV['HOME']; // user's home directory
/home/adam
Early versions of PHP automatically created PHP variables for
all environment variables by default. As of 4.1.0, php.ini-recommended disables this because of speed
considerations; however php.ini-dist continues to
enable environment variable loading for backward compatibility.
The $_ENV array is created only if the value of the
variables_order configuration directive contains
E. If $_ENV isn't available, use getenv( ) to retrieve an environment variable:
$path = getenv('PATH');
The getenv( ) function isn't available if you're
running PHP as an ISAPI module.