How to deal with PHP templates

Source: Internet
Author: User
Which PHP templates can separate PHP code from HTML code. What are their advantages and disadvantages? ------ Solution ------------------ Smarty1. speed: programs written in Smarty can achieve maximum speed improvement, which is relative to other template engine technologies. & Nbsp; 2. compiler type: a program written in Smarty must be compiled into a PHP file with non-template technology during runtime.
Which templates can separate PHP code from HTML code. What are their advantages and disadvantages?

------ Solution --------------------
Smarty
1. speed: programs written with Smarty can achieve the maximum speed improvement, which is relative to other template engine technologies.

2. compilation type: a program written in Smarty must be compiled into a non-template PHP file during runtime. this file adopts a mix of PHP and HTML, during the next Template access, the WEB request is directly converted to this file, instead of re-compiling the template (without modifying the source program)

3. cache technology: a cache technology used by Smarty to cache the HTML file that the user sees as a static HTML page. when the cache attribute of Smarty is set to true, during the cachetime period set by Smarty, user WEB requests are directly converted to this static HTML file, which is equivalent to calling a static HTML file.

4. plug-in technology: Smarty can customize plug-ins. Plug-ins are actually some custom functions.

5. You can use if/elseif/else/endif in the template. Using judgment statements in the template file can easily rearrange the template format.

Not suitable for Smarty

1. content to be updated in real time. For example, for a stock display, it often needs to update the data, resulting in frequent re-compilation of the template, so the use of Smarty for this type of program slows down the processing speed of the template.

2. small projects. Small projects because the project is simple and the artist and the programmer have one-person project, using Smarty will lose the advantage of rapid PHP development to a certain extent

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.