How to use smarty
This article mainly shows you "how to use smarty", the content is simple and easy to understand, the organization is clear, I hope to help you solve doubts, let Xiaobian lead you to study and learn "how to use smarty" this article.
Can be set in display
$smarty->display("demo.tpl",$_SERVER[REQUEST_URI]) to implement multiple caches for a template.
Now that the file has been cached, we can go to cache the file, without loop execution of the connection database, query. Use a function in smatry to judge
$smarty->iscached(demo.tpl"",",$_SERVER[REQUEST_URI]) The default value is"true"where the template is the same as the display.
There is a difference between smarty3 and smarty2.
$smarty->is_cached(demo.tpl"",",$_SERVER[REQUEST_URI]) smarty2
$smarty->iscached(demo.tpl"",",$_SERVER[REQUEST_UR]I) smarty3
However, there are some parts in the template that do not need to be cached, such as: user login, and comments on the article do not need to be cached, so we solve this problem.
1, in the php file, if the data does not need to be cached, it should be placed outside the iscached judgment.
2. In the template, if you don't need to cache the part, put it in... between.
That's all for "how to use smarty". Thanks for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!