閱讀關於DRY。如果你明白這一點,你會得到你的答案。
我建議你做這樣的:
<!doctype html>
<html lang="en">
<head>
<?php include'head.html.php') ?>
</head>
<body>
<?php include'header_navigation.html.php') ?>
<?php include'content.html.php') ?>
<?php include 'footer.html.php' ?>
</body>
</html>
head.html.php
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Your website title</title>
header_navigation.html.php
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About us</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
內容。 html.php
<section>
<article>
<h1>Your content title</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nihil, quos, saepe a similique totam excepturi enim natus voluptatum rerum eum veritatis aspernatur minus ipsum accusamus voluptate minima quis suscipit officia!</p>
</article>
</section>
footer.html.php
<!-- your scripts -->
<script type="text/javascript">
$(document).ready(function() {
});
</script>
似乎是一個反模式給我。瀏覽器可以原諒這一點,並顯示預期的輸出(一些瀏覽器可能,至少),但多次包含這些元素仍然是非常不正確的。任何由此不正確標記導致的行爲最多都是未定義的,在調試任何進一步的問題(如CSS/JavaScript故障)之前需要更正。 – David
這是一個解脫..它縫合真的不合邏輯! – user2950370