note 78224 deleted from function.realpath by peehaa

From: Date: Sun, 28 Apr 2019 09:50:20 +0000
Subject: note 78224 deleted from function.realpath by peehaa
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-210718@lists.php.net to get a copy of this message
Note Submitter: alex at bartl dot net ---- Sometimes it is helpful to check for the existance of a file which might be found by using the include_path like in <?php 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. <?php 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; } ?>

« previous php.notes (#210718) next »