Home >Backend Development >PHP Problem >What is the difference between php templates and frameworks
In PHP, templates generally refer to things in the View layer, which are used for browsing; while frameworks are used to implement the MVC design pattern and continue to be encapsulated into a complete system in the most basic code; It can be said that the template is an integral part of the framework.
Recommendation: "PHP Video Tutorial"
The template is for browsing, and the framework is the most basic The code continues to be encapsulated into a complete system.
The template is an integral part of the framework. In order to implement the mvc design pattern, the framework generally uses the template mechanism to write the V (view) layer to implement the V layer without PHP code. Where dynamic output or simple logical judgment is required, it is implemented based on template syntax and template tags. In this way, the writing work of the V layer code can be handed over to the front-end personnel, because the front-end personnel do not need to master PHP, but only need to master relatively simple template syntax and tags. The benefits of this are self-evident.
Smarty is a powerful template engine. The V layer code written in smarty is "compiled" - the template parsing engine "translates" according to the smarty grammar mechanism, and automatically "translates" the places with smarty tags into php code...
The framework can be said to be Such a thing - it is already a semi-finished product of an application, with a complete structure. You only need to complete your system according to your own needs. As an MVC framework, the template is only its V part.
Many frameworks have their own V layer mechanism, such as Zend Framework has Zend_View. But you can also integrate smarty into Zend Framework to replace Zend_View's template as the C part of its MVC.
The above is the detailed content of What is the difference between php templates and frameworks. For more information, please follow other related articles on the PHP Chinese website!