Forum Moderators: coopster

Message Too Old, No Replies

$_SERVER .vs. $_ENV ['DOCUMENT_ROOT'] . '/

my server can't make up its mind which to use

         

jamie

7:18 pm on Nov 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



my server (redhat 7.2) keeps on changing the way it inteprets the DOCUMENT_ROOT variable.

sometimes i have to use $_ENV['DOCUMENT_ROOT'] . 'html/files/etc

or

other times i have to use $_SERVER['DOCUMENT_ROOT'] . '/html/files/etc, with a forward slash before the directory.

at the moment in phpinfo() i can only find the SERVER version, but i know this already, cos i've had to s & r lots of instances of this ;-)

does anyone have a clue why it should be changing?

btw i have been trying to upgrade php lots over the last week, with lots of apachectl restarts. but i didn't manage to upgrade, so the original version of php is still being used?

cheers

coopster

11:36 pm on Nov 9, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The $_ENV superglobal variables are imported into PHP's global namespace from the environment under which the PHP parser is running. Many are provided by the shell under which PHP is running and different systems are likely running different kinds of shells, a definitive list is impossible. The PHP manual advises to see your shell's documentation for a list of defined environment variables.

The entries in the $_SERVER array are created by the webserver. Assuming you are running Apache, you need to check your DocumentRoot [httpd.apache.org] directive. The DocumentRoot should be specified without a trailing slash, therefore when you add the rest of your path, you would need to prefix it with your slash as you mentioned.

Personally, I'd go with the $_SERVER global and make sure your directives are correct.

jamie

7:48 am on Nov 10, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



thanks for explaining coopster. i'll stick with server in the future ;)

cheers