note 92619 modified in function.file-exists by thiago

From: Date: Fri, 31 Jul 2009 14:43:39 +0000
Subject: note 92619 modified in function.file-exists by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-158966@lists.php.net to get a copy of this message
Since file_exists does not offer a possibility to search in include_path.. <?php /* * Expanden file_exists function * Searches in include_path */ function file_exists_ip($filename) { if(function_exists("get_include_path")) { $include_path = get_include_path(); } elseif(false !== ($ip = ini_get("include_path"))) { $include_path = $ip; } else {return false;} if(false !== strpos($include_path, PATH_SEPARATOR)) { if(false !== ($temp = explode(PATH_SEPARATOR, $include_path)) && count($temp) > 0) { for($n = 0; $n < count($temp); $n++) { if(false !== @file_exists($temp[$n] . $filename)) { return true; } } return false; } else {return false;} } elseif(!empty($include_path)) { if(false !== @file_exists($include_path)) { return true; } else {return false;} } else {return false;} } ?> --was-- Since file_exists does not offer a possibility to search in include_path.. /* * Expanden file_exists function * Searches in include_path */ function file_exists_ip($filename) { if(function_exists("get_include_path")) { $include_path = get_include_path(); } elseif(false !== ($ip = ini_get("include_path"))) { $include_path = $ip; } else {return false;} if(false !== strpos($include_path, PATH_SEPARATOR)) { if(false !== ($temp = explode(PATH_SEPARATOR, $include_path)) && count($temp) > 0) { for($n = 0; $n < count($temp); $n++) { if(false !== @file_exists($temp[$n] . $filename)) { return true; } } return false; } else {return false;} } elseif(!empty($include_path)) { if(false !== @file_exists($include_path)) { return true; } else {return false;} } else {return false;} } http://php.net/manual/en/function.file-exists.php

« previous php.notes (#158966) next »