我已经搜索了实现此目标的方法,但是它似乎并不适用于所有路径,因此我想知道您是否可以为我提供有关如何执行此操作的指导:
这是结构:
Home Directoy
config.php
index.php
includes/
user_login.php
applicant_track.php
ucp/
index.php
当我尝试在ucp / index.php中包含include / user_login.php时,它不允许我说它找不到文件,我的代码在ucp / index.php中是:
if(!defined('root_path'))
{
define('root_path', realpath(dirname(__FILE__)));
}
include(root_path . '\config.php');
switch($_GET["a"])
{
case null: include(root_path . '\index.php'); break;
case "login": include(root_path . '\includes\user_login.php'); break;
}
这是我得到的:
Warning: include(E:\xampp\htdocs\aod_panel\ucp\config.php): failed to open stream:
我很乐意为您提供有关如何解决此问题的建议。
使用以下路径
define('root_path', realpath(dirname(dirname(__FILE__))));
而不是用于定义真实路径的代码。由于您的文件夹结构是这样的。
看到index.php位于ucp
文件夹中,但是您需要config.php的路径。因此,返回一个目录并获取config.php路径。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句