inc/globals.php
<?
require_once('functions.php');define('RELPATH', GetRelativePath());
?>inc/functions.php
function GetRelativePath() {
$RELPATH = str_replace(UpDirectory(__FILE__), '', dir_name($_SERVER['SCRIPT_NAME]));
$RELPATH = substr_count($RELPATH, '/');
if ( $RELPATH>0 )
$RELPATH = str_repeat('../', $RELPATH);
else
$RELPATH = '/'; return ConvertSlashes($RELPATH);
}function UpDirectory($directory, $level=1) {
while ( $level-- > 0 )
$directory = dirname(dirname($directory)); return ConvertSlashes($directory);
}function ConvertSlashes($st) {
$st = str_replace('\\\\', '/', $st);
$st = str_replace('\\', '/', $st); return $st;
}function dir_name($directory) {
return ConvertSlashes(dirname($directory));
}Chris Thomas wrote:
Is there anyway that i can get a url relative to my server for a script that is being run??
The script is being included in mulitple files and $_SERVER['SCRIPT_NAME'] just gives me the name of the file that is including the other scripts. Also $_SERVER['SCRIPT_FILENAME'] is returning nothing.
Thanks
Chris
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

