2009-12-23 92 views
0

需要一些帮助来解决此错误。新鲜的WordPress 2.9安装...致命错误:无法实例化不存在的类:directoryiterator

致命错误:无法实例不存在的类:directoryiterator在/home1/test/public_html/test2/wp-content/themes/mytheme/functions.php线471

function get_dirs($path = '.') { 
$dirs = array(); 
foreach (new DirectoryIterator($path) as $file) { //THIS IS LINE 471 
    if ($file->isDir() && !$file->isDot()) { 
     $dirs[] = $file->getFilename(); 
    } 
} 

return $dirs; 

}

回答

0

DirectoryIterator类是Standard PHP Library (SPL),这是在PHP 5 installed by default也许你正在使用PHP 4的一部分吗?

编辑

要获取有关PHP的安装信息,请使用phpinfo()。用这一行创建一个.php文件并在浏览器中打开它:

<?php phpinfo() ?> 
+0

我想这可能是罪魁祸首。它在wordpress的共享服务器上安装。我如何通过脚本查询PHP版本? – 2009-12-23 15:18:14

+0

假设它的版本4,我可以将该类添加到实用程序文件中吗? – 2009-12-23 15:18:55

+0

嗯,我想你会需要一个自定义的实现。 *您自担风险*,这是谷歌发现的例子:http://www.weberdev.com/get_example-4180.html – catchmeifyoutry 2009-12-23 15:23:04

相关问题