当我想用RecursiveIteratorIterator
and自动加载类时出现此错误spl_autoload_register
,
未捕获的异常“UnexpectedValueException”,带有消息“RecursiveDirectoryIterator::__construct():系统找不到指定的路径。(代码:3)
这是什么意思?
下面是我的类自动加载器,
function autoload_multiple_directory($class_name){
// List all the class directories in the array.
$array_directories = array(
'core/controller/',
'core/model/',
'core/helper/',
'core/ext/'
);
$parts = explode('\\', $class_name);
// Set the class file name.
$file_name = end($parts).'.php';
foreach($array_directories as $path_directory){
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($path_directory),
RecursiveIteratorIterator::SELF_FIRST
);
foreach ($iterator as $fileObject) {
if ($fileObject->isDir()) {
$files[] = str_replace('\\', '/', $fileObject->getPathname()).'/';
}
}
}
$array_directories = array_merge($array_directories,$files);
// Loop the array.
foreach($array_directories as $path_directory){
if(file_exists(WEBSITE_DOCROOT.$path_directory.$file_name)){
include WEBSITE_DOCROOT.$path_directory.$file_name;
}
}
}
spl_autoload_register('autoload_multiple_directory');
错误线指向new RecursiveDirectoryIterator($path_directory),
为什么?