Smarty template learning notes: Smarty introduction. 1. introduction Smarty is a PHP template engine written using PHP. it is one of the most famous PHP template engines in the industry. It separates the logic code from external content and provides a brief introduction
Smarty is a PHP template engine written using PHP. it is one of the most famous PHP template engines in the industry. It separates the logic code from the external content and provides an easy-to-manage and use method to combine the originally HTML code with the PHP code logic separation. Simply put, the purpose is to separate PHP programmers from the front-end, so that PHP programmers can change the logic content of the program without affecting the front-end page design, and re-modifying the page on the front-end will not affect the program logic, this is particularly important in projects with multiple partners.
2. what are the advantages of smarty?
A. speed: programs written using Smarty can increase the maximum speed, which is relative to other template engine technologies.
B. compile type: a program written in Smarty must be compiled into a PHP file with non-template technology during runtime. this file uses 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)
C. cache technology: a cache technology used by Smarty. it caches the HTML file that the user finally sees into 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.
D. plug-in technology: Smarty can customize plug-ins. Plug-ins are actually some custom functions.
E. you can use if/elseif/else/endif in the template. Using judgment statements in the template file can easily rearrange the template format.
3. however, pay attention to using smarty in the following situations.
A. content to be updated in real time. For example, for a stock display, it needs to update data frequently. Using smarty for this type of program slows down the processing speed of the template.
B. small projects. Small projects because the project is simple and the artist and programmer are both one-person projects, using Smarty will lose the advantage of rapid PHP development to a certain extent.
(PS: However, for the sake of project specifications, please try to use the template engine. As a matter of fact, the development speed will be faster. the above are problems that developers who are not used to the template engine encounter)
Worker Smarty is a PHP template engine written using PHP. it is one of the most famous PHP template engines in the industry. It separates logical code from external content and provides...