2014-03-13 64 views
2

我有一個FileA.php功能無法找到

function readDirectory($aPath) { 
    $list = Array(); 
    if(is_dir($aPath)) { 
     if ($dh = opendir($aPath)) { 
      while (($file = readdir($dh)) !== false) { 
       if(is_file("$aPath/$file") && $file != '.htaccess') { 
        $list[$file] = "$file"; 
       } 
      } 
      closedir($dh); 
     } 
    } 
    sort($list, SORT_STRING); 
    return $list; 
} 

這個函數和我FileB.php在FileC.php我FileA.php included()然後FileB.php included()要執行 。但我得到:

Fatal error: Call to undefined function readDirectory() in ..folder/FileC.php on line 2

無法弄清楚什麼是錯的。

+2

這顯然不包括在內。確保您的文件路徑正確。 – naththedeveloper

+3

嘗試使用'require'而不是'include'。如果找不到文件,'require'會返回一個錯誤(所以我們可以檢查問題是否是這樣)。可能您的文件位於不同的目錄中,因此您需要控制包含路徑 –

+0

請向我們展示如何包含這些文件並請[啓用*完整*錯誤報告](http://stackoverflow.com/questions/6575482/how- DO- - 啓用 - 錯誤報告功能於PHP)。 – PeeHaa

回答