我会将您的根文件夹添加到包含路径并从那里开始工作.
来自admin / test.php
set_include_path(implode(PATH_SEPARATOR, array(
realpath(__DIR__ . '/..'),
get_include_path()
)));
require_once 'class/main.class.php';
require_once 'includes/functions.php';
require_once 'config.php';
更新
如果我正确地关注你的问题,假设你想在config.php文件中定义它,你会做这样的事情
config.php文件
set_include_path(implode(PATH_SEPARATOR, array(
__DIR__,
get_include_path()
)));
require_once 'class/main.class.php';
require_once 'includes/functions.php';
管理员/ test.php的
require_once __DIR__ . '/../config.php';