Let's talk about the Template Selection in PHP Program Development

Source: Internet
Author: User
Tags php template

The PHP template is indeed easy to say and do. There are more than 20 options for a random number. pear contains 5 different templates, which is really a headache.

Never let everyone say that this is a good thing. Before you select a template, you 'd better find out what the real purpose of the template is? Simply put, the core purpose of a template is a team work. There are two main ways to work:

1. Separating HTML and PHP makes it easier for web designers to cooperate with PHP programmers.
 

2. The separation of display logic and transaction logic makes it easier and more flexible to change the core transaction logic and extend the application. That is to say, it makes the cooperation between programmers more pleasant. (This is often overlooked or misunderstood. I always think that the separation of display logic and transaction logic is to extract PHP from HTML, if so, why should PHP and html be mixed together ?)

It is easy to make the right choice by figuring out what the real purpose of this template is.
 

If you have only one php programmer but need to work with other web designers, you can select a template that can separate HTML and PHP, phplib (now seems to have integrated http://pear.php.net/package/HTML_Template_PHPLIB into Pear) or

FastTemplate is easy to use.
 

If your website interface is ugly and mainly completed by programmers, but the functions are complicated and more powerful extension functions are required, you need to separate all layers including the display logic, so don't use anything special. PHP itself is the best template. Note that in this case, you must design your program very seriously and always remember that what you want to separate is not PHP and html but business logic) and presentation logic ). This is why I have always been very resistant to something like Smarty, because the syntax of this Smarty is too complicated and too powerful, and almost re-invented a scripting language, (Even PHP programmers have to learn it again ). What is even more confusing is that the more powerful the script, the more likely it is to mix the transaction logic and the presentation logic, undermining the original intention of the template.
 

If you want to separate HTML from PHP, get a better visual design, and have a very powerful extension capability for the entire system to adapt to various html, xml, and wml interfaces, and you don't need to learn complex syntaxes and provide high running efficiency. This is a very challenging problem. Bad news is that no mature template can really meet this requirement. The good news is that it is not difficult to complete such a template, if you try Zope or ColdFusion, you will find the shadow of this template,

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.