自动加载


function AotuLoadFile($dirArray)
{
$rootPath=realpath(".");
$headSign="file://";
foreach ($dirArray as $dir) {
$utilityPath="$headSign$rootPath/$dir";
$dirInfo=scandir ($utilityPath);
foreach ($dirInfo as $fileName) {
$fullPath= "$dir/$fileName";
if(is_dir($fullPath))
{
continue;
}
$fileNameNotExtension=str_replace(".php","","".$fileName);
if(class_exists($fileNameNotExtension))
{
continue;
}

include $fullPath;
}
}
}





function __autoLoad($className)
{
$rootPath=realpath(".");
$headSign="file://";
$utilityPath="$headSign$rootPath";
$dirInfo=scandir ($utilityPath);
foreach ($dirInfo as $dir) {
if(is_dir("$utilityPath/$dir"))
{
$dirInfo2=scandir ("$utilityPath/$dir");
foreach ($dirInfo2 as $dir2) {
if(!is_dir("$utilityPath/$dir/$dir2")) {
if ("$className.php" == $dir2) {
include "$dir/$dir2";
return;
}
}
}
}
}
}

 

 

posted @ 2015-11-02 13:00  无为有道  阅读(211)  评论(0编辑  收藏  举报