Maison  >  Article  >  développement back-end  >  .tpl与.php,该怎么解决

.tpl与.php,该怎么解决

WBOY
WBOYoriginal
2016-06-13 12:20:291281parcourir

.tpl与.php
最近在学习smarty框架
看到一些 .tpl文件里写着html和php代码
.tpl与.php有什么区别
(个人想法:  纯php代码就用.php  php+html等混合代码用.tpl)
------解决思路----------------------
tpl 是 template (中文释义:模板) 的缩写

smarty 是一种模板引擎,它使用自定义的模板语言,实现了显示逻辑和业务逻辑的分离(分别对应 MVC 的 V 和 M)
使用模板引擎的好处在于:在设计业务逻辑代码时,完全不需要考虑以后将如何展示运行的结果。这就有可能时程序得以精益求精
而在做用户界面时,也不需要知道数据时怎么来的,只需将数据按界面需要显示出来就可以了

无论是否使用模板引擎,最终执行的都是 php+html 混合编码
------解决思路----------------------
.tpl只是模版,不管文件是以什么结尾,最终运行的文件都是.php
smarty 模板引擎就是做这种分离工作的,当然还有一起其他的功能

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn