The smarty template engine can implement page caching to accelerate page access after initialization.
To some extent, the smarty template ensures that the Code on the template page is neat and tidy, avoiding the combination of HTML tags and PHP.
When maintaining the business logic code, we can only modify the script file of the business logic code;
When page modification and page reconstruction are generated, we can only modify the page file.
PHP is only responsible for business logic and Data
The smarty template displays the data to the page because HTML tags do not have any logical functions.
Suggestions for using the smarty template:
1. Do not assign variables to the smarty template. Instead, organize and classify the data according to relevance and use a one-dimensional correlated array assign.
In the TPL file, data is obtained and displayed through array access using the smarty template.
Example: an online web hotel reservation website with a reservation navigation bar on all pages, such:
Data in the navigation bar: Check in date, check out date, adults, children, nights, extrabed, package
The seven data items should be related to the reservation. They can be combined into an array, and then assign in the past and called in TPL.
Instead of distributing each data to the assign, it is inconvenient to manage and modify the data.
The room information to be displayed in step 1 can be stored as an independent array and then called in TPL by assign, for example:
[Label] [smarty] smarty usage experience