Created
September 7, 2012 00:11
-
-
Save favrik/3661713 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* $strPathList is in the form of an include_paht: .:/usr/local/lib:etc | |
*/ | |
function GetValidPathFromList($strPathList) { | |
$arrPaths = explode(PATH_SEPARATOR, $strPathList); | |
foreach ($arrPaths as $strPath) { | |
if (file_exists($strPath)) { | |
return $strPath; | |
} | |
} | |
return false; | |
} | |
/** | |
* $strPathList is in the form of an include_paht: .:/usr/local/lib:etc | |
* $strFile is just a filename: file.inc or file.class.php | |
*/ | |
function IncludeFromPathList($strPathList, $strFile) { | |
$strPath = GetValidPathFromList($strPathList); | |
if ($strPath !== false) { | |
$strComputedFile = $strPath . DIRECTORY_SEPARATOR . $strFile; | |
include_once $strComputedFile; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment