471,075 Members | 1,342 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,075 software developers and data experts.

phpinfo() and $_SERVER['DOCUMENT_ROOT'] constant

I have just discovered that the value reported for
$_SERVER['DOCUMENT_ROOT'] by phpinfo is different from the value I
obtain when I run the following:

<?php echo $_SERVER['DOCUMENT_ROOT'] ?>

My natural assumption is to assume that this is a joke (like most of the
PHP language in my experience so far) - but seriously, does anyone know
why on earth a diagnostic tool like phpinfo() displays values that are
different from that obtained via a script call?

BTW - this is what explains my previous post - where I was wondering why
my require_once() was not working. I had blindly believed the values
spat out by phpinfo(0.

Its only under careful investigation, that I realized that the values
are different .. so I'm just going to "hack it", and simply hard code
the value, than believe anything phpinfo() has to say ... unless Im very
much mistaken ... can anyone explain this madness ?.
Jun 2 '08 #1
4 3963
On Mon, 12 May 2008 22:58:14 +0200, Ronald Raygun <in*****@domain.com>
wrote:
I have just discovered that the value reported for
$_SERVER['DOCUMENT_ROOT'] by phpinfo is different from the value I
obtain when I run the following:

<?php echo $_SERVER['DOCUMENT_ROOT'] ?>

My natural assumption is to assume that this is a joke (like most of the
PHP language in my experience so far) - but seriously, does anyone know
why on earth a diagnostic tool like phpinfo() displays values that are
different from that obtained via a script call?
Only it is called from another method/instance with another document root.
For a certain configured host in apache, it will always report the right
host, unless you yourself changed it. If you don't like working with PHP,
just don't work it. Don't knock it on the basis of your own errors. There
are certainly some faults with PHP, however nothing you mentioned is one
of them.
Its only under careful investigation, that I realized that the values
are different .. so I'm just going to "hack it", and simply hard code
the value, than believe anything phpinfo() has to say ... unless Im very
much mistaken ... can anyone explain this madness ?.
Most probable: it's a user reading error, check again.

Less probable: somewhere in the code, a wrong value is assigned to
$_SERVER, as it's sadly not read-only. The most likely case where this
could happen is within an IF statement actually assigning instead of
comparing.

Unprobable: different hosts configured with different roots, and not the
same context is checked against each other.

Very unprobable: a very weird specific PHP error, reinstall/recompile.
--
Rik Wasmus
[SPAM] Now temporarily looking for some smaller PHP/MySQL projects/work to
fund a self developed bigger project, mail me at rik at rwasmus.nl. [/SPAM]
Jun 2 '08 #2


Rik Wasmus wrote:

If you don't like working with PHP, just don't work it.

Ah, ... If life were that simple.
Jun 2 '08 #3
On 12 May, 22:28, Ronald Raygun <inva...@domain.comwrote:
Rik Wasmus wrote:

If you don't like working with PHP, just don't work it.

Ah, ... If life were that simple.
Life may not be that simple, but people sometimes are.
Jun 2 '08 #4
On Mon, 12 May 2008 23:28:05 +0200, Ronald Raygun <in*****@domain.com>
wrote:
Rik Wasmus wrote:

If you don't like working with PHP, just don't work it.

Ah, ... If life were that simple.
Ah, well, as long as you don't forget to read on in that post to the
possible scenario's & solutions mentioned.
--
Rik Wasmus
[SPAM] Now temporarily looking for some smaller PHP/MySQL projects/work to
fund a self developed bigger project, mail me at rik at rwasmus.nl. [/SPAM]
Jun 2 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by chops | last post: by
6 posts views Thread by olafmol | last post: by
6 posts views Thread by Tom | last post: by
4 posts views Thread by Chris | last post: by
6 posts views Thread by Jeff | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.