下面是確切的問題。我有一個自動加載功能,設置了一段代碼,看起來像這樣:爲什麼PHP在它明確存在時不包括我的文件?
if(file_exists($class_file))
{
include($class_file);
return true;
}
然而,當$class_file
設定爲一定值時,我得到一個包含錯誤:
Error String: include(includes/php/utilities/calendar_event_html.utility.php)
[function.include]: failed to open stream: No such file or directory
它的工作原理對其他文件很好,當我用調試器遍歷這段代碼時,很明顯PHP認爲文件存在,但似乎include
沒有。有沒有人知道發生了什麼?
也許PHP沒有權限訪問這個文件? – RaYell 2009-12-08 15:15:07
@ ApoY2k好的,你可以在錯誤中看到,內容是'includes/php/utilities/calendar_event_html.utility.php',但它可以很好地處理'include/php/utilities/calendar_header_html.utility.php ' - 因爲我事先做了'file_exists',所以這兩者都必須存在。 – 2009-12-08 15:19:42
上述代碼與您在應用程序中使用的代碼相同嗎?如果不是,包含是否發生在file_exists之外的其他文件中? – halfdan 2009-12-08 15:22:53