Smarty template to PHP script?
Smarty templates cannot be converted into PHP scripts, but they can be achieved by obtaining compiled templates. Smarty is a template engine written in PHP and is one of the most famous PHP template engines in the industry. , can be used to logically separate PHP code that is originally mixed with HTM code
Smarty advantages
1. Speed: Adopt Programs written in Smarty can achieve maximum speed improvements compared to other template engine technologies.
2. Compiled type: A program written in Smarty needs to be compiled into a non-template technology PHP file at runtime. This file uses a mixture of PHP and HTML. When accessing the template next time, the WEB request will be directly Convert to this file without recompiling the template (when the source program has not been changed)
3. Caching technology: a caching technology selected by Smarty, which can store the content that the user finally sees. The HTML file is cached into a static HTML page. When Smarty's cache attribute is set to true, the user's WEB request is directly converted to this static HTML file within the cachetime set by Smarty. This is equivalent to calling a Static HTML files.
4. Plug-in technology: Smarty can customize plug-ins. Plug-ins are actually some custom functions.
5. If/elseif/else/endif can be used in templates. Using judgment statements in template files can very conveniently reformat the template.
Not suitable for using Smarty
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.
Small projects. For small projects where the artist and programmer are both simple 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 standardization of 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 the template engine)
Recommended tutorial: "PHP Tutorial"
The above is the detailed content of Smarty template to PHP script?. For more information, please follow other related articles on the PHP Chinese website!