joel boonstra wrote:

On Thu, Feb 05, 2004 at 09:48:22PM +0000, Stuart wrote:

Eric Gorr wrote:

A solution I found was in dirA/index.php, to chdir( ".." ); before
the require_once, which moves the current directory to SiteRootDir and allows otherfuncs.php to be found ... is this the best way to solve this problem?

Qualify relative paths by prepending $_SERVER['DOCUMENT_ROOT'].'/' - I usually define a constant at the start of all scripts like so...


define('SITE_ROOT', $_SERVER['DOCUMENT_ROOT'].'/');


Why not use php's include_path setting? No need to define constants, no
need to worry about the location of your script relative to the document
root, and it works with more functions than just include() and
require().


I have found it to be the cleanest, most reliable, and most portable way
to deal with file paths.

joel



And if document root is different from include path? What if the include path is outside of document root? You CANNOT rely on include_path to accomplish this.

--
By-Tor.com
It's all about the Rush
http://www.by-tor.com

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



Reply via email to