failed to open stream: No such file or directory 問題大全,本文由烈火網小編收集整理,請在轉載時保留出處。
案例一:
(failed to open stream: No such file or directory)在IIS下PHP環境配置的目錄權限導致出錯的問題
原因及解決方法:
配置環境為 IIS + php
如果確認你的程序在其他環境下下可以正常運行而唯獨在Win 下的 IIS 出現類似如下的錯誤:
Warning: main(./Config.php): failed to open stream: No such file or directory in D:\wwwroot\Demo\Config.php on line 13
Fatal error: main(): Failed opening required './Config.php' (include_path='.;c:\php4\pear') in D:\wwwroot\Core\Config.php on line 13
這個問題主要是 由於Win NTFS盤下去除了everyone 權限引起的, 在安全權限中加個 Internet 來賓賬號就解決了.
操作步驟: D盤 -> 屬性 -> 安全 -> 添加 用戶 IUSR_XXXXX OK
案例二:
問題就是:
Warning: require_once(../lib/DBUtil.class.php) [function.require-once]: failed to open stream: No such file or directory in E:\phppro\dxh\service\ExpertService.class.php on line 2
Fatal error: require_once() [function.require]: Failed opening required '../lib/DBUtil.class.php' (include_path='.;C:\php5\pear') in E:\phppro\dxh\service\ExpertService.class.php on line 2
解決方法:
1.在require時加上dirname(__FILE__),像這樣: require_once(dirname(__FILE__)."/../lib/DBUtil.class.php");
2.如下理解 require_once實例:

//如果b.php被其他目錄里的a.php文件require 或者 include 去引用的話
require_once("./c.php"); //實際上調用的是a.php目錄下的c.php
require_once(dirname(__FILE__)."/c.php"); //實際上調用的是b.php目錄下的c.php
require_once("c.php"); //實際上調用的是b.php目錄下的c.php
?>
案例三:
運行php網站,出錯,內容如下:
Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required 'E:/php/www/mrsoft/注冊登錄模塊/index.php' (include_path='.;C:\php5\pear') in Unknown on line 0
文件結構:
解決方法:
apache不能解析上圖中“注冊登錄模塊”的中文URL,把它換成英文路徑即可。