首页 > 其他 > 详细

自动加载

时间:2015-11-02 14:01:27      阅读:228      评论:0      收藏:0      [点我收藏+]

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;
}
}
}
}
}
}

 

 

自动加载

原文:http://www.cnblogs.com/ck0074451665/p/4929869.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!