You want to get the value of an environment variable.
Use getenv():
1 |
$path = getenv('PATH'); |
Environment variables are named values associated with a process. For instance, in Unix, the value of getenv(‘HOME’) returns the home directory of a user:
1 |
print getenv('HOME'); // user's home directory |
PHP automatically loads environment variables into $_ENV by default. However, php.inidevelopment and php.ini-production disables this because of speed considerations.
If you frequently access many environment variables, enable the $_ENV array by adding E to the variables_order configuration directive. Then you can read values from the $_ENV superglobal array. For instance:
1 |
$name = $_ENV['USER']; |
The getenv() function isn’t available if you’re running PHP as an ISAPI module.