Home >Backend Development >PHP Tutorial >Let's talk about what PHP template engines have
PHP is an HTML-embedded scripting language executed on the server side, so the initial development template for most web applications developed in PHP is mixed-layer data programming. Although the MVC design pattern can forcefully separate program application logic and web page rendering logic, it only separates the input, processing, and output of the application. The web page rendering logic (view) will also be strongly coupled with HTML code and PHP programs. .
Type
There are many mature templates that can be applied in PHP, such as Smarty, PHPLIB, IPB, xingTemplate and dozens more. Using these template engines written in PHP can make your code context clearer and the structure more rational. It can also make website maintenance and updates easier, create a better development environment, and make it easier to combine development and design work. However, for a PHP programmer, no PHP template is the most suitable and perfect for him. Because PHP templates are popular things and are not developed for a certain person. If you can fully understand the advantages and disadvantages of templates based on a clear understanding of their characteristics and applications, you can know whether to choose to use a template or which template to use.
1. smarty
smarty is a PHP template engine developed based on PHP. It provides the separation of logic and external content. Simply put, the purpose is to separate PHP programmers from artists. The programmers who use it will not affect the page design of the artist when changing the logical content of the program, and the artist will not re-modify the page. It affects the program logic of the program, which is particularly important in multi-person cooperation projects.
2. Template Lite
Template Lite is a very fast and small HTML template engine. The engine supports most of the features and filters that the Smarty template engine has.
3. TinyButStrong
TinyButStrong (TBS) is a PHP template engine that can cleanly separate PHP scripts and HTML files. TBS is designed so that any visual HTML editor can be used to write TBS HTML template pages.
4. XTemplate
XTemplate is a template engine suitable for PHP. It allows HTML code to be stored separately from PHP code. XTemplate contains many useful features such as nested blocks and various types of interpolation variables. The code is very concise and optimized.
5. Savant
Savant is a powerful but lightweight object-oriented PHP template engine. Unlike its template system, Savant does not compile templates into PHP by default, but uses PHP itself as its template language so you don't need to learn a new markup system. Savant has an object-oriented template plug-in system and output filters that allow you to quickly add new behaviors to it.
6. phemplate
phemplate is a simple and fast PHP template engine. It allows adding variables and some dynamic blocks including loops to the template. This template engine can separate presentation from logic, which means you can extract all HTML content from PHP scripts. Designers can change the HTML at will without worrying about messing up your PHP scripts.
7. Dwoo
Dwoo is a PHP5 template engine. Compatible with Smarty templates, it is completely rewritten based on Smarty syntax. Supports extending its functionality through plug-ins.
8. Sugar
Sugar is a template engine similar to Smarty, with a concise and easy-to-understand syntax.
9. Twig
Twig is a flexible, fast and safe PHP template language. It compiles templates into optimized raw PHP code. Twig has a sandbox model to evaluate untrusted template code. Twig consists of a flexible lexer and parser that allows developers to define their own tags, filters and create their own DSL.
10. FXL Template
FXL Template is an easy-to-use template engine that provides all the basic functions of a template system. Supports simple text/array allocation, blocks and nested blocks. Has good regular expressions and simple template syntax for the fastest possible template processing.
11. H2o
H2o is a PHP template engine, which has beautiful template tags in Django style. Most of its concepts are derived from Django templates. Features: Has readable and natural syntax. Reuse template inclusions and inheritance. Internationalization support. Various cache support.
12. ns-template
Around May 2010, I felt that the concept of DEDE tags actively calling data was suitable for CMS, so I developed some Smarty custom modifiers and custom tags, but The performance is poor during execution and the overhead is measured in s, which is intolerable. Analysis and tracking cannot be fast due to the principle of custom tag implementation. So a lot of smarty syntax and custom tag functions were added to the dz template. After more than a year of online operation and bug fixes, and making up for the multi-level nesting problem of DEDE tags, this version was released under a more stable condition.
13. Blade
Blade is a simple and powerful template engine under the Laravel framework. Blade is very fast because it uses only a handful of regular expressions to compile your templates into raw PHP code. Unlike controller layout, the Blade template engine is driven by template inheritance and template fragments. All Blade template files must use the Blade.blade.php file extension.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of Let's talk about what PHP template engines have. For more information, please follow other related articles on the PHP Chinese website!