Re: best way to properly build an include path *regardless* from where I am calling the include?

From: Date: Tue, 07 Jul 2009 03:58:11 +0000
Subject: Re: best way to properly build an include path *regardless* from where I am calling the include?
References: 1 2 3 4 5 6 7 8  Groups: php.general 
Request: Send a blank email to php-general+get-294985@lists.php.net to get a copy of this message
I'm not sure how this could be made simpler. $site_root = realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR; Call that in any file in the root of *your* web directories, and you have what is essentially the "document root" for *your* site. Presumably, you know the *relative* directories of all your files. Simply append those relative directories + filenames to the $site_root variable, and you're done. Paul
Paul, you are right. what you say above is very simple. I guess I just did a poor job of communicating what I was after. What I wanted was: ($_SERVER['DOCUMENT_ROOT'] ..but an equivelent that would work on any server, even if ($_SERVER['DOCUMENT_ROOT'] was turned off. SO that I could build a universal global include path that would not break in any page, even if I later moved the page up or down a directory.. never requiring editing, despite the page's URL changes. -G

« previous php.general (#294985) next »