我搜索的方法來做到它,所以它會工作,但沒有人似乎對所有路徑的工作,所以我在想,如果你可以給我如何做到這一點的方向:相對/絕對路徑問題
這是結構:
Home Directoy
config.php
index.php
includes/
user_login.php
applicant_track.php
ucp/
index.php
當我試圖包括包括/ user_login.php在UCP/index.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:
我很樂意爲如何解決這個問題提供建議。
告訴我實際路徑config.php所在的位置。 –
您是否嘗試過:'包括$ _ SERVER [ 'DOCUMENT_ROOT'] '/包括/ user_login.php';' – SuperDJ
你的index.php代碼是在\ UCP,所以root_path是\ UCP,但config.php文件不在\。 ucp ... – Armage