471,072 Members | 1,365 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,072 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 3332
*** 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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Tom | last post: by
4 posts views Thread by Chris | last post: by
2 posts views Thread by George Zervakos | last post: by
4 posts views Thread by Ronald Raygun | 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.