Introduction to the Smarty of smarty template Learning notes _php skills

Source: Internet
Author: User
Tags php template smarty template

1. Introduction

Smarty is one of the most famous PHP template engines in the industry, using PHP as a template for PHP templates. It separates the logical code from the external content, provides an easy to manage and use method to separate the PHP code from the original HTML code. Simply speaking, the goal is to make the PHP programmer with the front-end separation, so that PHP programmers change the logic of the program will not affect the front-end page design, the front page will not affect the redesign of the program logic, which in many people cooperation project is particularly important.

2. What are the advantages of smarty?

A, speed: the use of Smarty written program can achieve maximum speed, which is relative to other template engine technology.

b, compile-type: Using Smarty written program in the runtime to compile into a non-template technology php file, this file using a mix of PHP and HTML, the next time the template to access the Web request directly into this file, And no more template recompilation (without changes to the source program)

C, caching technology: Smarty selection of a caching technology, it can be the user finally see the HTML file into a static HTML page, when the set Smarty cache property is True, Converting a user's Web request directly into this static HTML file during the Cachetime period of the Smarty setting is equivalent to calling a static HTML file.

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

E, if/elseif/else/endif can be used in the template. Using Judgment statements in template files makes it easy to rearrange templates.

3, however, the use of smarty in the following situations should be noted

A, what needs to be updated in real time. For example, like the stock display, it needs to update the data frequently, and this type of program using Smarty will slow down the template processing speed.

b, small projects. Small projects because the project is simple and art and programmer with a person's project, the use of smarty will be to some extent lost the advantages of PHP development quickly.

PS: However, for the overall project specification, please try to use the template engine. Actually accustomed to, the development speed will be quicker, above is not using the custom template engine the problem which the developer encounters.

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.