11
我正在完成一個代碼段,列出目錄中的文件。我沒有問題列出目錄中的文件,但出於某種原因,我可以使用isDot()方法來確保文件不是「。」。要麼 」..」 。在此錯誤以下結果如下:我切換到使用遞歸迭代器我用的目錄迭代器爲什麼isDot()會失敗? (PHP)
Fatal error: Call to undefined method SplFileInfo::isDot() in ....
之前,它工作得很好。下面的代碼有什麼問題嗎?它應該工作。
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($pathToFolder));
//if there is a subdirectory it makes sure the proper extension is passed
foreach($files as $name => $file){
if (!$file->isDot()) { //this is where it shuts me down
$realfile = str_replace($pathToFolder, "", $file);
$url = getDownloadLink($folderID, $realfile);
$fileArray[] = $url;
}
}
很好的解釋!感謝您向我解釋這一點。 – thomascirca 2011-06-14 00:41:19