note 78224 added to function.realpath
| From: | alex at bartl dot net | Date: | Wed, 03 Oct 2007 15:25:23 +0000 |
| Subject: | note 78224 added to function.realpath | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131040@lists.php.net to get a copy of this message | ||
Sometimes it is helpful to check for the existance of a file
which might be found by using the include_path like in
include("file_from_include_path.php");
A simple function iterates the include_path and tries all
possibilites, returns translated_local_path on success or false
if not found.
function mappath($path_to_translate){
$IncludePath=explode(PATH_SEPARATOR,get_include_path());
foreach($IncludePath as $prefix){
if(substr($prefix,-1)==DIRECTORY_SEPARATOR)
$prefix=substr($prefix,0,-1);
$try_path=sprintf("%s%s%s"
,$prefix,DIRECTORY_SEPARATOR,$path_to_translate);
if(file_exists($try_path))return($try_path);
}
return false;
}
----
Server IP: 212.24.129.51
Probable Submitter: 81.10.159.39
----
Manual Page -- http://www.php.net/manual/en/function.realpath.php
Edit -- https://master.php.net/note/edit/78224
Del: integrated -- https://master.php.net/note/delete/78224/integrated
Del: useless -- https://master.php.net/note/delete/78224/useless
Del: bad code -- https://master.php.net/note/delete/78224/bad+code
Del: spam -- https://master.php.net/note/delete/78224/spam
Del: non-english -- https://master.php.net/note/delete/78224/non-english
Del: in docs -- https://master.php.net/note/delete/78224/in+docs
Del: other reasons-- https://master.php.net/note/delete/78224
Reject -- https://master.php.net/note/reject/78224
Search -- https://master.php.net/manage/user-notes.php