473,385 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 4111
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: chops | last post by:
I need the path of the script that is running. Unfortunately it is not in the $_SERVER array when running a script through the CLI. Through a browser I can strip the script name off, e.g...
6
by: olafmol | last post by:
Hello, on my windows NT4 server with IIS4 and PHP Version 4.3.1 i don't have any "DOCUMENT_ROOT" environment var. Is there any reason i dont get this? Can i do something about it? I need this...
6
by: Tom | last post by:
I'm trying to dynamically adjust the path for one of my scripts using this: $script_path = str_replace( $_SERVER, "", dirname(realpath(__FILE__)) ) . DIRECTORY_SEPARATOR; The problem: the...
4
by: Chris | last post by:
I'm working on a large intranet group site with a lot of pages, file types, folders, subfolders, etc. I am using the include ('../includes/file.php') , but I would like to have a single snippet...
4
by: monomaniac21 | last post by:
Why does this find the file: <img src="<?=$_SERVER?>/images/viessmann_header_logo.gif"> But this does not? $right_content = $_SERVER."includes/content/content.php";
12
by: comp.lang.php | last post by:
Env: Windows XP, Apache 1.33, PHP 5.2.0 <? echo is_dir($_SERVER) . " for dir = " . $_SERVER); ?>
6
by: Jeff | last post by:
Is $_SERVER alway available? I ask this because I've seen on windows that the perl equivalent was missing. Is this settable and accessible the same way (ie not having to use global)? Jeff
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.