2015-03-02 60 views
-5

我正在建立一个网站,基本上它包含7-8页。只是想知道,如果我必须再次编写整个编码& ...就像NAVBAR,HEADER,FOOTER和其他东西?如何在创建网站时使用布局/模板?

如果我想进行一些更改,我需要做什么?我必须手动为每个页面编辑代码?

+1

可能重复的[如何为所有网页制作相同的布局](http://stackoverflow.com/questions/9872912/how-to-make-same-same-layout-for-all-web-pages) – jbutler483 2015-03-02 09:40:38

+0

plz解释m非常新oo – blackpearlisuchiha 2015-03-02 09:41:08

+0

请在php中包含什么*语言*? asp.net?等等 – jbutler483 2015-03-02 09:42:23

回答

2

也许您应该考虑使用PHP include声明以避免必须通过多个文件重复代码。

下面是一个例子:

的header.php

<header> 
    <!-- All the code for your header --> 
<header> 

myWebpage1.php

<!-- All the head stuff, title, meta, styles, etc. --> 
<body> 
<?php 
    include "header.php"; 
?> 
<h1>My webpage 1</h1> 
<!-- On and on... --> 

myWebpage2.php

<!-- All the head stuff, title, meta, styles, etc. --> 
<body> 
<?php 
    include "header.php"; 
?> 
<h1>My webpage 2</h1> 
<!-- On and on... --> 

您可以使用include状态只要它们是PHP文件,就可以在所有的网页文件中使用。

的更多信息是:http://php.net/manual/en/function.include.php

希望这有助于。

相关问题