所以我做了一个脚本,以便我可以使用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');
?>