Home > Backend Development > PHP Tutorial > Smarty Template Study Notes - Introduction to Smarty_PHP Tutorial

Smarty Template Study Notes - Introduction to Smarty_PHP Tutorial

WBOY
Release: 2016-07-13 10:29:34
Original
728 people have browsed it

1. Introduction

Smarty is a template PHP template engine written in PHP. It is currently one of the most famous PHP template engines in the industry. It separates logical code and external content, providing an easy-to-manage and use method to logically separate PHP code that is originally mixed with HTML code. Simply put, the purpose is to separate PHP programmers from the front-end, so that PHP programmers can change the logical content of the program without affecting the front-end page design, and the front-end re-modifying the page will not affect the program logic of the program. It is particularly important in cooperative projects.

2. So what are the advantages of smarty?

a. Speed: Programs written using Smarty can achieve maximum speed improvements, which is compared to other template engine technologies.

b. Compiled type: A program written in Smarty must be compiled into a non-template technology PHP file at runtime. This file uses a mixture of PHP and HTML. The WEB request will be directly converted to this the next time the template is accessed. file without recompiling the template (when the source program has not been changed)

c. Caching technology: A caching technology selected by Smarty. It can cache the HTML file that the user finally sees into a static HTML page. When the cache attribute of Smarty is set to true, the During the cachetime period, the user's WEB request is directly converted into this static HTML file, which 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 templates. Using judgment statements in template files can very conveniently reformat the template.

3. However, please pay attention when using smarty in the following situations

a. Content that needs to be updated in real time. For example, like stock display, which needs to update data frequently, using smarty for this type of program will slow down template processing.

b. Small projects. For small projects where the artist and programmer are both involved because the project is simple, using Smarty will lose the advantage of PHP's rapid development to a certain extent.

(PS: However, for the sake of standardizing the entire project, please try to use the template engine. In fact, if you get used to it, the development speed will be faster. The above are the problems encountered by developers who are not used to using the template engine)

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/775001.htmlTechArticle1. Introduction Smarty is a template PHP template engine written in PHP. It is currently the most famous PHP template in the industry. One of the engines. It separates logical code and external content, providing a...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template