【问题标题】:require_once show warning and fatal error but in correct dirrequire_once 显示警告和致命错误,但在正确的目录中
【发布时间】:2020-09-27 15:32:02
【问题描述】:

在我创建 index.php 并向我显示此错误消息之前,我的网站运行正常。

警告:require_once(../_asset/faker/vendor/fzaninotto/faker/src/autoload.php):无法打开流:C:\xampp\htdocs\belajar\covid_config\config 中没有这样的文件或目录.php 在第 10 行

致命错误:require_once():在 C 中打开所需的 '../_asset/faker/vendor/fzaninotto/faker/src/autoload.php' (include_path='C:\xampp\php\PEAR') 失败: \xampp\htdocs\belajar\covid_config\config.php 在第 10 行

这是我的程序,可能会导致错误(index.php)

include "_config/config.php";

这是我的 config.php

require_once "../_asset/faker/vendor/fzaninotto/faker/src/autoload.php";

我的文件夹表:从 htdocs 开始

belajar-covid-_asset
             |-_config
             |-auth
             |-dashboard
             |-index.php

【问题讨论】:

    标签: php require


    【解决方案1】:

    requirerequire_onceincludeinclude_once语句中,PHP根据以下优先顺序搜索源文件:

    1. 完整的路径名,如果有的话(例如include 'c:/my_include/autoload.php';
    2. include_path(在你的情况下是C:\xampp\php\PEAR
    3. 调用脚本自己的目录
    4. 当前工作目录

    您需要的文件('../_asset/faker/vendor/fzaninotto/faker/src/autoload.php')不在这些位置。

    See PHP manual for details

    【讨论】:

      猜你喜欢
      • 2013-11-11
      • 2011-03-14
      • 2014-10-21
      • 2019-10-31
      • 1970-01-01
      • 2016-08-15
      • 2016-08-05
      • 1970-01-01
      • 2019-01-28
      相关资源
      最近更新 更多