Пример #1
0
 public static function autoLoad($classname)
 {
     // 自动加载项目类文件
     $modulePath = PRO_PATH . "/" . ($GLOBALS['PROJECT_REQUEST_MODULE'] ? $GLOBALS['PROJECT_REQUEST_MODULE'] : APP_NAME);
     $corePath = __NOTEPHP__ . "/Core";
     $autoLoadPath = array($modulePath, $corePath);
     foreach ($autoLoadPath as $path) {
         if ($fileHandler = ergodicPath($path, $classname . EXTS)) {
             break;
         }
     }
     // 加载失败则返回FALSE,让队列函数继续加载
     if ($fileHandler === false) {
         return false;
     }
 }
Пример #2
0
function ergodicPath($path, $fileNameToSearch)
{
    if (is_dir($path)) {
        $fp = opendir($path);
        while ($item = readdir($fp)) {
            if ($item == "." or $item == "..") {
                continue;
            }
            $secondPath = $path . "/";
            if ($item == $fileNameToSearch) {
                return require_once $secondPath . $item;
            } elseif (is_dir($loopEgiPath = $secondPath . $item)) {
                ergodicPath($loopEgiPath, $fileNameToSearch);
            }
        }
    } else {
        return false;
    }
}