note 32242 added to function.realpath

From: Date: Wed, 21 May 2003 10:47:43 +0000
Subject: note 32242 added to function.realpath
Groups: php.notes 
Request: Send a blank email to php-notes+get-48727@lists.php.net to get a copy of this message
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; } ---- Manual Page -- http://www.php.net/manual/en/function.realpath.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32242 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32242&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32242&report=yes

« previous php.notes (#48727) next »