473,324 Members | 2,535 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,324 software developers and data experts.

$_SERVER['DOCUMENT_ROOT']

Is $_SERVER['DOCUMENT_ROOT'] 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
Aug 3 '08 #1
6 3490
*** Jeff escribió/wrote (Sun, 03 Aug 2008 11:00:52 -0400):
Is $_SERVER['DOCUMENT_ROOT'] alway available?
Not necessarily. And even if it exists it might be wrong (I've seen such
case in GoDaddy).
Whatever the case, $_SERVER is not write-only.
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor en cubitos: http://www.demogracia.com
--
Aug 3 '08 #2
Álvaro G. Vicario wrote:
*** Jeff escribió/wrote (Sun, 03 Aug 2008 11:00:52 -0400):
> Is $_SERVER['DOCUMENT_ROOT'] alway available?

Not necessarily. And even if it exists it might be wrong (I've seen such
case in GoDaddy).
Whatever the case, $_SERVER is not write-only.

If you're running PHP as a module, then yes, it is available. As a CGI,
generally not.

I've never seen it wrong - it comes directly from the server. If it is
incorrect, there is a major server configuration problem or the script
itself is messing things up. And if it were server configuration, I
would expect to see other problems as well.

Also, I think mean it is not READ_ONLY. Which is true - anyone can
write to it. But that's true of all of the superglobals.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Aug 3 '08 #3
..oO(Jerry Stuckle)
>Álvaro G. Vicario wrote:
>*** Jeff escribió/wrote (Sun, 03 Aug 2008 11:00:52 -0400):
>> Is $_SERVER['DOCUMENT_ROOT'] alway available?

Not necessarily. And even if it exists it might be wrong (I've seen such
case in GoDaddy).
Whatever the case, $_SERVER is not write-only.


If you're running PHP as a module, then yes, it is available. As a CGI,
generally not.
On Apache servers it should always be available, regardless of the SAPI.
One of my hosts runs PHP as FastCGI and the docroot variable is there.
>I've never seen it wrong - it comes directly from the server. If it is
incorrect, there is a major server configuration problem or the script
itself is messing things up.
Agreed.

Micha
Aug 3 '08 #4
Michael Fesser wrote:
.oO(Jerry Stuckle)
>Álvaro G. Vicario wrote:
>>*** Jeff escribió/wrote (Sun, 03 Aug 2008 11:00:52 -0400):
Is $_SERVER['DOCUMENT_ROOT'] alway available?
Not necessarily. And even if it exists it might be wrong (I've seen such
case in GoDaddy).
Whatever the case, $_SERVER is not write-only.

If you're running PHP as a module, then yes, it is available. As a CGI,
generally not.

On Apache servers it should always be available, regardless of the SAPI.
One of my hosts runs PHP as FastCGI and the docroot variable is there.
>I've never seen it wrong - it comes directly from the server. If it is
incorrect, there is a major server configuration problem or the script
itself is messing things up.

Agreed.

Micha
Good do know, Micha - thanks. But I know on IIS servers is is not
available if you run as a cgi.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 3 '08 #5
Jerry Stuckle wrote:
Michael Fesser wrote:
>.oO(Jerry Stuckle)
>>Álvaro G. Vicario wrote:
*** Jeff escribió/wrote (Sun, 03 Aug 2008 11:00:52 -0400):
Is $_SERVER['DOCUMENT_ROOT'] alway available?
Not necessarily. And even if it exists it might be wrong (I've seen
such
case in GoDaddy).
Whatever the case, $_SERVER is not write-only.
If you're running PHP as a module, then yes, it is available. As a
CGI, generally not.

On Apache servers it should always be available, regardless of the SAPI.
One of my hosts runs PHP as FastCGI and the docroot variable is there.
>>I've never seen it wrong - it comes directly from the server. If it
is incorrect, there is a major server configuration problem or the
script itself is messing things up.

Agreed.

Micha

Good do know, Micha - thanks. But I know on IIS servers is is not
available if you run as a cgi.
That would explain why the perl equivalent under IIS is not there as
perl typically runs as a CGI.

I'm running php on the same IIS server and $_SERVER['DOCUMENT_ROOT']
is visible, so this must be because it is running as a module. Is the
module preferred and more common under IIS? I sometimes do some work in
IIS and I've always found that perl was a bit brain dead about where it
was. This must be the cgi issue again. I'm not sure exactly what it is
but my general experience with windows administrators is that they have
more questions than answers!

Jeff
>
Aug 4 '08 #6
While the city slept, Álvaro G. Vicario feverishly typed:
Whatever the case, $_SERVER is not write-only.
Which is good, as write-only data is rarely useful ;-)

Cheers,
Nige

--
Nigel Moss | http://www.nigenet.org.uk
Email not valid. ni***@dog.nigenet.org.uk - take the dog out!
"You're mother ate my dog!", "Not all of him..."
Aug 4 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

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...
2
by: George Zervakos | last post by:
Hello, I'm new to php and was wondering if someone could help me out with the best way to accomplish this. I have Solaris 9/Apache 1.3.31/PHP 5.1.4 that I compiled from source code and...
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); ?>
4
by: Ronald Raygun | last post by:
I have just discovered that the value reported for $_SERVER by phpinfo is different from the value I obtain when I run the following: <?php echo $_SERVER ?> My natural assumption is to assume...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.