require_once中的相对路径不起作用
2022-08-30 07:17:58
我有以下结构
otsg
> class
> authentication.php
> database.php
> user.php
> include
> config.inc.php
> encryption.php
> include.php
> session.php
> index.php
> registration.php
包含.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';
在索引中.php我包含的页面
require_once 'include/include.php';
当我打开页面索引时.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
提前致谢