Re: Getting The Document Root

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jeremy Privett wrote:
John Nichel wrote:

$_SERVER['DOCUMENT_ROOT']
http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server


Nope. I've already tried that... $_SERVER['DOCUMENT_ROOT'] contains /home/jeremy/public_html/test/ ... All I want is to the public_html part.


'DOCUMET_ROOT' will return what the web server's document root is, no matter what directory on that web server the script is run.

ie, I'm running apache, look here....

http://www.nichel.net/docroot.php
http://www.nichel.net/test/docroot.php
http://www.nichel.net/bob/docroot.php
http://www.nichel.net/bob/fred/docroot.php

All four of those 'docroot.php' scripts are the same:

<?php


echo ( $_SERVER['DOCUMENT_ROOT'] );


?>

But they're in four different directories. Document root is just that, it's the directory where Apache (or other web servers) start serving files from for the particular domain.

Either you're webserver is seriously hosed (I can't even imagine how), or document root is not what you're thinking it is. If you place a script three levels below the 'test' directory which echo's out document root, what's the output?

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
jnichel@xxxxxxxxxxxxxxxxxxxxxxxxxxx

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux