PHP $_ENV where are they stored
I've compiled my own PHP / apache setu开发者_开发技巧p on our dev box at work. However the $_ENV['SERVER_Name'];
isn't showing anything. Why is this?
Array keys are case sensitive. Try:
echo $_ENV['SERVER_NAME'];
Failing that, you could always try:
echo $_SERVER['SERVER_NAME'];
The manual says ('SERVER_NAME'):
The name of the server host under which the current script is executing. If the script is running on a virtual host, this will be the value defined for that virtual host.
And for your question of where they are stored:
Not all at the same place, some come from the system, some come from your Apache configuration, some from your PHP configuration, ...
But you can set your own ENV vars by adding:
SetEnv MY_ENVVAR value
in your httpd.conf
Dump the entire contents of the array and see for yourself, it's likely an issue with the capitalization of your key
print_r($_ENV);
var_dump($_ENV);
You can list all the $_ENV, $_SERVER, $_REQUEST variables etc. with
<?php phpinfo(); ?>
As karim79 says, the problem right now is probably that you're using mixed case, but this will help you debug in future.
You can also say
<?php print_r($_ENV); ?>
to get just the contents of $_ENV.
精彩评论