【问题标题】:PHP installation warning: [function.require-once]: failed to open streamPHP安装警告:[function.require-once]:打开流失败
【发布时间】:2012-01-21 15:18:15
【问题描述】:

尝试在本地安装 groupon 克隆的脚本时遇到问题。 我正在使用在 windows7 中运行的 XAMPP

Apache/2.2.17 (Win32) mod_ssl/2.2.17 
OpenSSL/0.9.8o 
PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1
MySQL client version: mysqlnd 5.0.7-dev - 091210 - $Revision: 304625

这就是我尝试运行 index.php 的原因:

Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\php\PEAR\Config.php on line 80

Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\php\PEAR\Config.php on line 166

Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\php\PEAR\Config\Container.php on line 111


Warning: require_once(DOCUMENT_ROOT/system/plugins/common.php) [function.require-once]: failed to open stream: No such file or directory in C:\Users\xxxx\Documents\Eclipse\xxxx\system\includes\library.inc.php on line 17

Fatal error: require_once() [function.require]: Failed opening required 'DOCUMENT_ROOT/system/plugins/common.php' (include_path='.;C:\xampp\php\PEAR') in C:\Users\xxxx\Documents\Eclipse\xxxx\system\includes\library.inc.php on line 17

php 文件的开头是这样的:

session_start();
require_once ('config.php');        // this is the one that defines DOCUMENT_ROOT
require_once ('functions.php');
require_once ('functions_theme.php');
require_once ('fns.php');

这是第 17 行:

    require_once (DOCUMENT_ROOT.'/system/plugins/common.php');

DOCUMENT_ROOT 在之前加载的 config.php 文件中是这样定义的:

define("DOCUMENT_ROOT",$_SERVER['DOCUMENT_ROOT']);

希望有人能提供帮助。

是的,文件在那个目录中(已经检查过:P)。

【问题讨论】:

  • 显然没有包含其他 PHP 文件,或者没有运行该行。
  • 您确定包含define 语句的文件在您尝试包含文件之前确实已加载吗? Warning: require_once(DOCUMENT_ROOT/system/plugins/common.php) 部分似乎表明 DOCUMENT_ROOT 尚未定义。
  • 在调用其他文件之前加载定义常量的文件。
  • 1.您的代码示例是从您的代码中复制的,还是手动输入到问题中? 2.能不能展示一个更完整的脚本(比如上面那个错误的16行)? 3. 这是唯一的警告吗? 4. 另外,当你在定义它之后立即var_dump(DOCUMENT_ROOT); 会发生什么 - 你得到任何输出吗?
  • 我已经用您提出的问题更新了问题。希望你能帮助我

标签: php file-io stream xampp require-once


【解决方案1】:

DOCUMENT_ROOT 常量未正确解析(我认为您包含的定义它的文件未正确包含)并且 PHP 正在回退到使用字符串 DOCUMENT_ROOT

【讨论】:

  • 是的,我不知道为什么在调用另一个我收到警告的文件之前会加载原因。
猜你喜欢
  • 2011-10-17
  • 1970-01-01
  • 1970-01-01
  • 2019-12-08
  • 2014-06-12
  • 2015-07-21
  • 1970-01-01
  • 1970-01-01
  • 2011-08-04
相关资源
最近更新 更多