include("/file.php") - document root
I may be losing my mind. I swear I've been able to use something like
And it would grab file.php located in the document root no matter where that line of code was in the directory structure. But for the life of me I can't find an environment that respects that.
I know there are a bizillion functions available on php.net for setting $_SERVER['document_root'] but I was hoping to avoid that by using the almighty single '/'.
Am I losing my mind?
Have you tried this?
That will include a file at the same level as the current file. I'm asking if I had file A 8 directories deep in a site, and I wanted to include file B at the root of the site.. how could I do it with just a '/' as it does in html/css/etc ?
Originally Posted by ayvegh
include $_SERVER['DOCUMENT_ROOT'] . '/file.php';
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
How to Ask Questions the Smart Way
(not affiliated with this site, but well worth reading)
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)