Home > php教程 > php手册 > body text

php模板smarty

WBOY
Release: 2016-06-13 11:21:06
Original
1286 people have browsed it

 说说 php模板 smarty
php的模板技术应该是经常提到的,象比较出名的phplib fasttemplate,都基本上实现了MVC的模式,功不可磨,现在用这2个模板的好象不多了,因为有另外的模板类 smarty ,smarty 和phplib 这些模板类的最主要的区别是,smarty 加了缓存的功能,每次打开程序不用都重新编译模板。
下面来说我用过smarty后,对其的看法。
smarty 并没有做的最好,因为它编译后的模板太过臃肿,你可以打开smarty编译后的模板页面,里面都是些对象,而且很复杂,PHP对对象变量处理相比是很慢的,而且编译后的模板是不需要程序员去看的,何苦要搞的这么复杂,会影响速度。
另外,想用smarty,还需要熟悉它的一些专门的语法,好比又要学习一门新的语言(虽然不是很复杂,但是也是很麻烦的)。
最后,smarty很死,几乎无法定义自己想要的模板标签。
下面介绍一种感觉不错的模板技术。discuz!的模板函数。
discuz!的模板函数就是把模板中的标签,直接替换成php的语法,最后程序执行的结果实际是php和html混和的程序,这样程序速度是最快,没有人会反对这个说法吧。
discuz!的模板函数很简洁,只有短短的几十行,比起smarty,要简洁太多了,这么简洁的代码,如果你要添加新的功能或者标签是非常简单的,同样实现MVC,而且速度比smarty绝对快。实现了灵活性和高速的完美结合。
discuz!的模板函数在 其源代码中的 /include/template.php 文件中,有兴趣的朋友,可以去研究下。
 
 



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!