2009-12-23 20 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

相關問題