【发布时间】:2015-11-13 01:29:27
【问题描述】:
我有 3 个文件:database.php、initialize.php 和 config.php。 这 3 个文件位于名为:
的文件夹下usr/loca/nginx/html/phpcode/php/999_projects/test/include/
database.php
<?php
echo "before";
require_once('initialize.php');
echo "after";
echo LIB_PATH;
?>
initialize.php
<?php
// DIRECTORY_SEPARATOR is a PHP pre-defined constant
// (\ for Windows, / for Unix)
defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR);
defined('SITE_ROOT') ? null :
define('SITE_ROOT', $_SERVER["DOCUMENT_ROOT"].DS.'phpcode'.DS.'php'.DS.'999_projects'.DS.'test');
defined('LIB_PATH') ? null : define('LIB_PATH', SITE_ROOT.DS.'includes');
// load config file first
require_once(LIB_PATH.DS.'config.php');
?>
config.php
<?php
// Database Constants
defined('MYSQL_DSN') ? null : define("MYSQL_DSN", "mysql:host=localhost;dbname=talkback");
defined('DB_USER') ? null : define("DB_USER", "user");
defined('DB_PASS') ? null : define("DB_PASS", "pass");
?>
运行 database.php 后,我得到以下信息:
警告: 需要一次(/usr/local/nginx/html/phpcode/php/999_projects/test/includes/config.php): 无法打开流:中没有这样的文件或目录 /usr/local/nginx/html/phpcode/php/999_projects/test/include/initialize.php 第 16 行
与
致命错误:require_once():需要打开失败 '/usr/local/nginx/html/phpcode/php/999_projects/talkback/includes/config.php' (include_path='.:/usr/share/php:/usr/share/pear') 在 /usr/local/nginx/html/phpcode/php/999_projects/talkback/include/initialize.php 第 16 行
这 3 个文件具有适当的权限,并且 Web 服务器也有权访问这些文件。
过去几个小时(!)我已经尝试修复它,但是,我找不到我缺少的东西。
有人可以帮忙吗?
谢谢,
Qwerty
【问题讨论】:
-
经常遇到这个错误,要快速排除故障,请按照以下步骤操作:stackoverflow.com/a/36577021/2873507
标签: php