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:wwwrootDemoConfig.PHP on line 13
Fatal error: main(): Failed opening required './Config.PHP' (include_path='.;c:PHP4pear') in D:wwwrootCoreConfig.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:PHPprodxhserviceExpertService.class.PHP on line 2
Fatal error: require_once() [function.require]: Failed opening required '../lib/DBUtil.class.PHP' (include_path='.;C:PHP5pear') in E:PHPprodxhserviceExpertService.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
?>
案例三:
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:PHP5pear') in Unknown on line 0
文件结构:
解决方法: