Re: Getting The Document Root
| From: | Jeremy Privett | Date: | Thu, 02 Feb 2006 16:41:29 +0000 |
| Subject: | Re: Getting The Document Root | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-229741@lists.php.net to get a copy of this message | ||
John Nichel wrote:
Jeremy Privett wrote:Thanks guys, that did the trick! :-) -- Jeremy Privett [ http://www.jeremyprivett.com ] Founder - Lead Software Developer - Hosting Systems Administrator Omega Vortex (http://www.omegavortex.com)John Nichel wrote:'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? Aha. So that DOES work. I see what the problem is now. I'm testing off of a sub-domain, so the document root is the root for that sub-domain. That's why it was tripping me up.$_SERVER['DOCUMENT_ROOT'] http://www.php.net/manual/en/reserved.variables.php#reserved.variables.serverNope. I've already tried that... $_SERVER['DOCUMENT_ROOT'] contains /home/jeremy/public_html/test/ ... All I want is to the public_html part.