所以我做了一個腳本,以便我可以使用includes來獲得我的頁眉,頁面,然後頁腳。如果一個文件不存在404,這一切都有效。現在我的問題是我應該如何獲得網頁的結束頁面。例如,獲取頁面URL爲了使用它包括
我想讓它變成這樣,當有人轉到example.com/home/test時,它會自動包含test.php文件。
道德故事。如何獲取頁面名稱。然後用它來「屏蔽」頁面的末尾,這樣我就不需要讓每個URL都是something.com/home/?p=home
繼承我的代碼到目前爲止。
<?php
include($_SERVER['DOCUMENT_ROOT'].'/home/lib/php/_dc.php');
include($_SERVER['DOCUMENT_ROOT'].'/home/lib/php/_home_fns.php');
$script = $_SERVER['SCRIPT_NAME']; //This returns /home/index.php for example =/
error_reporting(E_ALL);
include($_SERVER['DOCUMENT_ROOT'].'/home/default/header.php');
if($_GET["p"] == 'home' || !isset($_GET["p"])) {
include($_SERVER['DOCUMENT_ROOT'].'/home/pages/home.php');
} else if(file_exists($_SERVER['DOCUMENT_ROOT'].'/home/pages/'.$_GET["p"].'.php')) {
include($_SERVER['DOCUMENT_ROOT'].'/home/pages/'.$_GET["p"].'.php');
} else {
include($_SERVER['DOCUMENT_ROOT'].'/home/default/404.php');
}
include($_SERVER['DOCUMENT_ROOT'].'/home/default/footer.php');
?>