Nightchild
01-20-2008, 06:21 AM
I am trying to create a base URL from which to build all other resource calls. The file this code is in resides in a /includes folder. I first explode the path then reassemble it leaving off the script filename and the '/include' directory.
So '//nexus/raw/include/test.php' becomes 'http://nexus/raw/
Is there a more elegant way of doing this?
// constant for the WWW base - used to assemble web paths
$temp = explode("/", $_SERVER['SCRIPT_NAME']);
$temp2 = 'http://' . $_SERVER['HTTP_HOST'];
for ($x=0; $x < count($temp)-2; $x++) {
$temp2 .= $temp[$x] . '/';
}
define ("URL_BASE", $temp2);
So '//nexus/raw/include/test.php' becomes 'http://nexus/raw/
Is there a more elegant way of doing this?
// constant for the WWW base - used to assemble web paths
$temp = explode("/", $_SERVER['SCRIPT_NAME']);
$temp2 = 'http://' . $_SERVER['HTTP_HOST'];
for ($x=0; $x < count($temp)-2; $x++) {
$temp2 .= $temp[$x] . '/';
}
define ("URL_BASE", $temp2);