【问题标题】:PHP Warning: require() failed to open stream: No such file or directoryPHP 警告:require() 无法打开流:没有这样的文件或目录
【发布时间】:2018-07-18 21:03:28
【问题描述】:

我在尝试运行 php 脚本时遇到以下问题:

/usr/bin/php /home/meet/web/online.php 0

我收到以下错误消息:

PHP Warning:  require(/home/meet/web/wee/weeAutoload.php): failed to open stream: No such file or directory in /home/meet/web/wee/wee.php on line 425

Warning: require(/home/meet/web/wee/weeAutoload.php): failed to open stream: No such file or directory in /home/meet/web/wee/wee.php on line 425
PHP Fatal error:  require(): Failed opening required '/home/meet/web/wee/weeAutoload.php' (include_path='.:/usr/share/pear:/usr/share/php') in /home/meet/web/wee/wee.php on line 425

Fatal error: require(): Failed opening required '/home/meet/web/wee/weeAutoload.php' (include_path='.:/usr/share/pear:/usr/share/php') in /home/meet/web/wee/wee.php on line 425

第 425 行的代码是:

//require(WEE_PATH . 'weeAutoload' . CLASS_EXT);
require("/home/meet/web/wee/weeAutoload.php");
weeAutoload::addPath(WEE_PATH);

我检查了,文件/home/meet/web/wee/weeAutoload.php存在于服务器上。

我做错了什么?

提前感谢您的宝贵帮助。

【问题讨论】:

  • 可能是路径问题。 WEE_PATH 中的内容是什么?
  • 我假设您的服务器是 Linux,文件名是否与 require 语句中的内容完全相同(区分大小写)? ls -l /home/meet/web/wee/weeAutoload.php的输出是什么
  • @Devon 如果是权限问题,错误会有所不同。
  • @Devon 当我对目录没有执行权限时,无论文件是否存在,我都会收到“权限被拒绝”。读取权限无关紧要。
  • 这是一个操作系统错误代码,不是 PHP 自己做出的区分。

标签: php require


【解决方案1】:

修正...我的错误

我只需要在与 online.php 文件位于同一文件夹后运行脚本

cd /home/meet/web
/usr/bin/php /home/meet/web/online.php 0

就是这样

谢谢你们的帮助:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-07-24
    • 2017-10-24
    • 2017-06-20
    • 2017-06-04
    • 2014-01-04
    • 2012-11-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多