tags:

views:

284

answers:

5

Hi I've compiled my own PHP / apache setup on our dev box at work. However the $_ENV['SERVER_Name']; isn't showing anything. Why is this?

+4  A: 

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.

karim79
A: 

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.

Grandpa
+2  A: 

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);
Alan Storm
A: 

Yeah I know sorry I meant $_ENV['SERVER_NAME'];

So are they provided by the shell environment. So in my case it's bash. so I need to set a system wide enviroment variable called SERVER_NAME right?

Ageis
+1  A: 

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

tharkun