我正在建立一个具有以下结构的网站。但\(user password)
和<html>
标记是在我的索引页面中,还是应该放在我的header.php中,然后是页脚中的<head>
和</body>
?
</html>
或者这更正确吗?
header.php
// In here I have my navbar, topbar etc there is on all pages.
index.php
include ('header.php')
<html>
<head>
</head>
<body>
Content
</body>
</html>
include ('footer.php');
footer.php
// Footer is the same on all pages
答案 0 :(得分:2)
就个人而言,我会构造它,所以html / head / body标签只在index.php中。
的index.php:
<html>
<head>
</head>
<body>
<?php
include 'navigation.php';
// default displays page welcome.php
// otherwise get page name from query string
$page = 'welcome.php';
if (!empty($_GET['page'])) {
$page = $_GET['page'].'.php';
}
include $page;
include 'footer.php';
?>
</body>
</html>
navigation.php:
<div class="nav">...</div>
的welcome.php:
<div class="container">
Welcome page content...
</div>
footer.php:
<div class="footer">...</div>
现在你可以有另一个页面文件,如
about.php:
<div class="container">
About page content...
</div>
并转到index.php?page=about
查看。