【发布时间】:2018-01-21 03:19:45
【问题描述】:
尝试打开我正在接管的项目的索引文件时出现以下错误:
Warning: require_once(core_services/logging.php): failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/app/docroot/www.website.com/index.php on line 7
Fatal error: require_once(): Failed opening required 'core_services/logging.php' (include_path='.:/Applications/XAMPP/xamppfiles/lib/php') in /Applications/XAMPP/xamppfiles/htdocs/app/docroot/www.website.com/index.php on line 7
错误引用的代码如下所示:
7 require_once "core_services/logging.php";
8 $logger=new syslog_class(__FILE__,LOG_DEBUG);
我通过定义文件路径并回显它以及logging.phpin 终端的内容来检查文件路径是否存在,并且返回很好,当我在第 6 行获取当前工作目录时,它返回 @987654324 @,我假设它正在定义我的根文件夹。
不知道如何解决这个问题,如果有人对方法有任何想法,我很想听听他们的意见,因为我的 PHP 有点生疏,而且缺乏 wordpress 的上下文。
编辑:到目前为止我尝试过的方法
require 'core_services/logging.php';
require '/core_services/logging.php';
require './core_services/logging.php';
require '../core_services/logging.php';
require '/Applications/XAMPP/xamppfiles/htdocs/app/docroot/www.website.com/core_services/logging.php';
require realpath(dirname(__FILE__)) .'/core_services/logging.php';
require(__DIR__"/../core_services/logging.php");
require_once 'core_services/logging.php';
require_once '/core_services/logging.php';
require_once './core_services/logging.php';
require_once '../core_services/logging.php';
require_once '/Applications/XAMPP/xamppfiles/htdocs/app/docroot/www.website.com/core_services/logging.php';
require_once realpath(dirname(__FILE__)) .'/core_services/logging.php';
require_once __DIR__"/../core_services/logging.php";
我也证实这不是权限问题。
【问题讨论】:
-
试试
require_once realpath(dirname(__FILE__)) .'/core_services/logging.php'; -
这种方法不走运,它返回相同的错误,只是更新尝试的文件路径。
标签: php require require-once