Home  >  Article  >  Backend Development  >  php template smarty_PHP tutorial

php template smarty_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:05:03719browse

Let’s talk about php template smarty
PHP’s template technology should be mentioned often. For example, the famous phplib fasttemplate basically implements the MVC model, which is a great contribution. It seems that not many people use these two templates now. Because there is another template class smarty, the main difference between these template classes smarty and phplib is that smarty has a caching function, so you don’t need to recompile the template every time you open the program.
The following is my opinion on smarty after using it.
smarty does not do the best because its compiled templates are too bloated. You can open the template page compiled by smarty, which is full of objects and very complicated. PHP's processing of object variables is very complicated. It's slow, and programmers don't need to look at the compiled template, so why bother making it so complicated, which will affect the speed.
In addition, if you want to use smarty, you need to be familiar with some of its specialized syntax, which is like learning a new language (although it is not very complicated, it is still very troublesome).
Finally, smarty is very dead, and it is almost impossible to define the template tags you want.
The following introduces a template technology that feels good. The template function of discuz!
discuz!’s template function is to directly replace the tags in the template with PHP syntax. The final result of the program execution is actually a program that mixes PHP and HTML. This way the program is the fastest. No one will object to this statement. .
discuz!’s template function is very concise, with only a few dozen lines. Compared with smarty, it is much more concise. With such a concise code, if you want to add new functions or tags, it is very simple and can be implemented in the same way. MVC, and it's definitely faster than smarty. Achieving the perfect combination of flexibility and high speed.
discuz!’s template function is in the /include/template.php file in its source code. Friends who are interested can study it.




www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445147.htmlTechArticleLet’s talk about php template smarty. PHP’s template technology should be often mentioned, such as the more famous phplib fasttemplate. Basically implemented the MVC model, the contribution is indispensable, now using these two templates...
Statement:
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