function.file_exists_incpath.php
Check if a file exists in the include path
- Version: 1.2.1
- Author: Aidan Lister <aidan@php.net>
- Link: http://aidanlister.com/repos/v/function.file_exists_incpath.php
- Return: mixed The full path if file exists, FALSE if it does not
- Views: 22159
- Downloads: 1878
Source
<?php
/**
* Check if a file exists in the include path
*
* @version 1.2.1
* @author Aidan Lister <aidan@php.net>
* @link http://aidanlister.com/repos/v/function.file_exists_incpath.php
* @param string $file Name of the file to look for
* @return mixed The full path if file exists, FALSE if it does not
*/
function file_exists_incpath ($file)
{
$paths = explode(PATH_SEPARATOR, get_include_path());
foreach ($paths as $path) {
// Formulate the absolute path
$fullpath = $path . DIRECTORY_SEPARATOR . $file;
// Check it
if (file_exists($fullpath)) {
return $fullpath;
}
}
return false;
}
?>
Comments