This template is good. how can I use it? No, let's look down. Well, this is also good, or else & hellip; this is the first day of the arrival, what I did & mdash; pick a template. The beautiful templates are fascinating. Below we use php to implement simple page template replacement. First paste the project directory structure:... "> <LINKhref =" http: // www. php10
"This template is good. how can I use it? No, let's look down. Well, this is also good, or ......"
This is the first day of the discussion. what I did was pick a template. The beautiful templates are fascinating.
Below we use php to implement simple page template replacement.
First paste the project directory structure:
Tpl_test is the project directory. the templates directory contains two templates, one and two. here, only the header and the last are changed, so there are only two files, footer. php and header. php.
The code in index. php is posted below:
// Simple template replacement example
$ Tpl = isset ($ _ GET ['tpl'])? $ _ GET ['tpl']: 1; // The first template by default.
Include "templates/". $ tpl. "/header. php"; // header
?>
Under a small test
Include "templates/". $ tpl. "/footer. php"; // footer
?>
The code must perform some judgment and other processing on $ _ GET ['tpl'], which is omitted here.
$ Tpl variable to get the template name. for convenience, the url is selected here (you can get the template name from various channels, such as the database), and then load the corresponding header according to the template name. php and footer. php. to put it bluntly, load the page template by changing the path.
The following only posts the header. php code of template 1. Template 2 only needs to be changed accordingly:
<Br/> This is Template 1. <br/>
Template 1 |
Template 2
This is the header of template 1.
The code is simple. Below:
Template 1:
Template 2:
This is just an introduction.
There are too many ways to change the page template, depending on how you create and how to make full use of your imagination.
You don't have to worry about how simple and useless the above code is.
When you look at the complex interior, you will find a lot of simplicity.