Home  >  Article  >  Backend Development  >  Template framework for making static websites with PHP 1_PHP tutorial

Template framework for making static websites with PHP 1_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:28:31706browse

Templates can improve the structure of your website. This article explains how to use a new feature of PHP 4 and the template class to skillfully use templates to control page layout in a website composed of a large number of static HTML pages.
Outline:
=======================================
Separate functionality and layout
Avoid duplication of page elements
Template framework for static websites
================================ ===

Separate functionality and layout
First let’s look at the two main purposes of applying templates:

Separate functionality (PHP) and layout (HTML)
Avoid pages Element Repeating
The first purpose is the most talked about purpose, and it envisions a situation where a group of programmers write PHP scripts that generate the content of the page, while another group of designers designs the HTML and graphics to control the page's content. Final appearance. The basic idea of ​​separating functionality and layout is to enable these two groups of people to write and use an independent set of files: programmers only need to care about files that only contain PHP code and do not need to care about the appearance of the page; while page designers can use their own Design your page layout with the most familiar visual editor, without worrying about breaking any PHP code embedded into the page.
If you have watched a few tutorials about PHP templates, then you should already understand how templates work. Consider a simple page part: the top of the page is the header, the left is the navigation bar, and the rest is the content area. This kind of website can have the following template files:


Template example

{HEADER}
{LEFTNAV}{CONTENT}



Template framework for making static websites with PHP 1_PHP tutorial

Foo

Bar

You can see how the page is constructed from these templates: the main template controls the layout of the entire page; the header template and leftnav template control the common elements of the page. Identifiers inside curly braces "{}" are content placeholders. The main benefit of using templates is that interface designers can edit these files according to their own wishes, such as setting fonts, modifying colors and graphics, or completely changing the layout of the page. Interface designers can edit these pages with any ordinary HTML editor or visualization tool, because these files only contain HTML code, without any PHP code.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/531769.htmlTechArticleTemplate can improve the structure of the website. This article explains how to use a new function and template class in PHP 4 to skillfully use templates to control page layout in a website composed of a large number of static HTML pages...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn