If there must be multiple autoload functions, spl_autoload_register() allows for this. It effectively creates a queue of autoload functions, and runs through each of them in the order they are defined. By contrast, __autoload() may only be defined once.
第二个参数是如果加载不到是否抛出异常
第三个参数是是否加入到队列头部
第二个参数是如果加载不到是否抛出异常
第三个参数是是否加入到队列头部
2016-08-22
function library($class) {
$file = DIR_SYSTEM . 'library/' . str_replace('\\', '/', strtolower($class)) . '.php';
if (is_file($file)) {
include_once(($file));
return true;
} else {
return false;
}
}
spl_autoload_register('library');
spl_autoload_extensions('.php');
$file = DIR_SYSTEM . 'library/' . str_replace('\\', '/', strtolower($class)) . '.php';
if (is_file($file)) {
include_once(($file));
return true;
} else {
return false;
}
}
spl_autoload_register('library');
spl_autoload_extensions('.php');
2016-08-22