Website Architecture

From: Date: Thu, 05 Feb 2004 21:34:40 +0000
Subject: Website Architecture
Groups: php.general 
Request: Send a blank email to php-general+get-176936@lists.php.net to get a copy of this message
I've got a directory structure similar to this: SiteRootDir index.php dirA
    index.php
dirB
    funcs.php
otherfuncs.php In the SiteRootDir/index.php, I've got: require_once( dirB/funcs.php ); in funcs.php, I've got: require_once( otherfuncs.php ); which works because SiteRootDir/index.php is the location from which files are looked for. However, in dirA/index.php, I've got: require_once( ../dirB/funcs.php ); and require_once( otherfuncs.php ) in funcs.php cannot be found. 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? A seperate, but related question.... funcs.php contains statements of the form: echo "<a href=\"directoryname\">linkname</a><br>"; forming a relative URL. Again, this would point to a different location depending on whether dirA/index.php or SiteRootDir/index.php called the function containing this relative URL and I want them to point to the same location. I was able to find a solution by doing the following: function AFunction( $toRoot ) { $location = $toRoot . "locationFromSiteRootDir"; echo "<a href=\"$location\">linkname</a><br>"; } So, from dirA/index.php, I would call AFunction like: AFunction( ".." ); Is this the best way to solve this problem? Thank you.

« previous php.general (#176936) next »