A little understanding of smarty

Source: Internet
Author: User

I think Smarty is still relatively simple, but the feeling is still a little trouble, Smarty is the template engine, my personal understanding, it is to separate the output of the code content and style.

Smarty compile-time processing is the source PHP file, template file (may call multiple or more than one), source PHP file ... This means that the original PHP file is not affected by other processing and output. So the Smarty template file can be either full HTML or part of it. Smarty processing process smarty PHP source files, first compiled into intermediate files (also PHP), if the cache is enabled, and then according to the compilation file generated cache files (also PHP), the part that needs to be cached is all hard-coded. Each subsequent visit accesses the compiled file (if it already exists), compiles multiple calls at a time (which can be multiple times of a single file, or multiple files), and if caching is enabled and the cache file is not expired, the cache file is accessed directly and the compiled file is skipped. Once the compiled file is generated, it will not be automatically updated unless the template file or configuration file changes. The source PHP file modification does not cause recompilation. Once the compilation file is regenerated, the cache file will inevitably regenerate.


We can build different PHP source files folder, put the PHP files written in a certain category in different folders. Then create a custom config file in each folder, create a new $smarty in the config file, and then put all the different folders of the PHP file cache, config file, plugin, template, compile directory are set to the same cache, Config file, plugin, template, compile directory so that all PHP source files under this folder can refer to the configuration file to get the same configuration

A little understanding of smarty

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.