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.
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php