Home >Backend Development >PHP Problem >Why not write the html file in php
Why not write the html file in php
1. If you write the html code in the php code, not only will the php code It is confusing, and there is no syntax support in the editor;
2. The core feature of PHP is that it can embed PHP code into HTML code, and there is syntax support, so HTML is not written in PHP.
Template engine recommendation
PHP is an HTML embedded scripting language executed on the server side, so most For web applications developed with PHP, the initial development template 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. .
Twig: Twig is a template engine from Symfony. It is very easy to install and use. It operates somewhat like Mustache and liquid.
Plates: Plate is inspired by Twig and overloads the native features of PHP. This opens the door for you if you don't want to use a template language that requires compilation.
Smarty: Smarty is a very old PHP template engine. It was my initial choice for using templates in this language. Although it is updated less frequently and lacks some features of the new generation of template engines, it is still worth a look.
Recommended tutorial: "PHP Tutorial"
The above is the detailed content of Why not write the html file in php. For more information, please follow other related articles on the PHP Chinese website!