Re: Website Architecture

From: Date: Thu, 05 Feb 2004 22:07:28 +0000
Subject: Re: Website Architecture
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-176949@lists.php.net to get a copy of this message
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 -- [ joel boonstra | gospelcom.net ]

« previous php.general (#176949) next »