码迷,mamicode.com
首页 > 其他好文 > 详细

自动加载

时间:2015-11-02 14:02:00      阅读:151      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!