我有一个 spl_autoload 被调用,但问题是第二个自动加载没有执行,我不知道为什么。使用此代码此代码脚本应该死。我从文件夹数组中删除类,自动加载将起作用。我的代码如下所示:
<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors','On');
/*** nullify any existing autoloads ***/
spl_autoload_register(null, false);
/*** specify extensions that may be loaded ***/
spl_autoload_extensions('.php');
function dataLoader($class) {
foreach (array(PV_CORE.DS.'data'.DS, PV_CORE.DS.'system'.DS, PV_CORE.DS.'cms'.DS, PV_CORE.DS.'util'.DS,PV_CORE.DS.'components'.DS, PV_CORE.DS.'template'.DS) as $folder){
if (is_file($folder.$class.'.php')) {
include_once $folder.$class.'.php';
}
}//end foreach
}
function testLoader($class) {
die();
$filename = $class. '.php';
$file =PV_CORE.DS.'data'.DS.$filename;
if (!file_exists($file)) {
return false;
}
require_once $file;
}
spl_autoload_register('dataLoader');
spl_autoload_register('testLoader');