2015-03-02 58 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

希望這有助於。

相關問題