Php implements simple page template replacement

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.