每页的HTML主题

时间:2018-08-02 07:51:49

标签: php html css

我正在为我的php项目创建一个主题。我想通过创建一个简单的theme.html页面并将其包含在每个页面中来减少代码量。

你能帮我吗?

示例theme.html

<html>
<body>
<h1>Welcome to panel</h1>
<ul>
  <li><a class="home"  href="#">Home</a></li>
  <li><a class="about" href="#">About us</a></li>
  <li><a class="contact" href="#">Contact us</a></li>
</ul>
<!-- content -->
<div class="content"><!-- other page codes will write here --></div>
<!-- content -->
</body>
<html>

现在我想将此代码包括到index.html中,并向内容div编写表单代码?帮帮我...

2 个答案:

答案 0 :(得分:1)

您可以使用php来做  为此,您必须像.php这样保存文件index.html into index.php 然后添加如下文件

<?php include 'theme.php';?>

答案 1 :(得分:0)

您还可以使用twig,这是一个很棒的php模板管理器(最初是为Symfony制作的),非常易于使用。