我有以下结构
otsg
> class
> authentication.php
> database.php
> user.php
> include
> config.inc.php
> encryption.php
> include.php
> session.php
> index.php
> registration.php
include.php文件具有以下内容
ini_set('display_errors', 1);
error_reporting(E_ALL);
ini_set('include_path',ini_get('include_path').':/Applications/MAMP/htdocs/otsg/:');
require_once 'config.inc.php';
require_once '../class/database.php';
require_once '../class/user.php';
require_once 'encryption.php';
require_once 'session.php';
require_once '../class/authentication.php';
并且在index.php页面中,我包括了
require_once 'include/include.php';
当我打开页面index.php时,出现以下警告和致命错误。我不明白是什么原因导致此错误。当我给出绝对路径时,它可以工作。但是我相信绝对的路线不是一个好主意。
Warning: require_once(../class/database.php) [function.require-once]: failed to open stream: No such file or directory in /Applications/MAMP/htdocs/otsg/include/include.php on line 9
Fatal error: require_once() [function.require]: Failed opening required '../class/database.php' (include_path='.:/Applications/MAMP/bin/php5.3/lib/php:/Applications/MAMP/htdocs/otsg/include/:') in /Applications/MAMP/htdocs/otsg/include/include.php on line 9
提前致谢
我通常做的Objective-C,并试图让我的手在PHP脚本和悲伤地看到我已经浪费了2小时搞清楚如何正确包括PHP文件。X代码使事情变得如此简单。
—
rohan-patel 2014年
一个人经常遇到此错误,并迅速对其进行故障排除,请按照以下步骤操作:stackoverflow.com/a/36577021/2873507
—
Vic Seedoubleyew