|
Posted by Steve on 03/24/07 22:02
btw, all of these reference this script...it just determines what your
relative path is given where a script is accessed based on your directory
structure. based on the system on which you run, you may need to take out
the - 1 at the end of line 4. i use this because even though there is a
$_SERVER variable letting you know this same information, it is reliant on
php compiled options and versions of php...this is the sledgehammer
approach.
======== relative.path.php
<?
$parsedUri = dirname($_SERVER['PHP_SELF']);
$relativeUri = str_replace('/', '', $parsedUri);
$relativePath = strlen($parsedUri) - strlen($relativeUri) - 1;
if ($relativePath < 0){ $relativePath = 0; }
$relativePath = str_repeat('../', $relativePath);
if (!$relativePath){ $relativePath = './'; }
?>
Navigation:
[Reply to this message]
|