note 32242 deleted from function.realpath by aidan
| From: | aidan@php.net | Date: | Sun, 29 Aug 2004 21:50:50 +0000 |
| Subject: | note 32242 deleted from function.realpath by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-75609@lists.php.net to get a copy of this message | ||
Note Submitter: taliesin at taliesin dot com
----
Modification of given code. Now when you use the code by including a file with these procedures it
will generate the correct baseurl.
This should work
Taliesin :)
function mapPath($file) {
if (substr($file,0,1)=="/"){
$file = substr($file,1);
}
$currentPath = dirname($_SERVER["SCRIPT_NAME"]);
if($currentPath=="/")
$Path = "./";
else
$Path = str_repeat("../", substr_count($currentPath, "/"));
return $Path.$file;
}
function basePath()
{
return realpath(dirname(__File__)."/".mapPath("/"));
}
function absolutePath($file)
{
$file = basePath().$file;
if(substr(basePath(), 0, 1) != "/")
$file = str_replace('/', '\\', $file);
return $file;
}