请问smarty模板怎么用,他的速度比phplib快吗?

bcmath 2003-08-31 09:21:12
加精
RT
...全文
429 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
igenus 2003-09-27
  • 打赏
  • 举报
回复
我不同意楼上说的。。smarty更适合团队开发的大型项目。他的cache功能太COOL了。

phplib用起来才是麻烦。

看这里:http://www.phpe.net/articles/361.shtml

这篇文章已经写得很清楚了。
DFlyingchen 2003-08-31
  • 打赏
  • 举报
回复
phplib也算是名声在外了,二者的选择确实有一个习惯的问题。
feel8 2003-08-31
  • 打赏
  • 举报
回复
smarty的具体用法可以看他的文档,挺全的,http://smarty.php.net
中文翻译版:http://www.hiweed.com/xoops/modules/mydownloads/visit.php?cid=2&lid=102

smarty速度应该比phplib快吧,别人试验得出结果,第一次浏览时他比phplib慢,以后浏览时速度均快于phplib,php官方推荐的东东,不过俺还是比较习惯使用phplib
「已注销」 2003-08-31
  • 打赏
  • 举报
回复
smarty是一个很完整的系统,以其为核心用在小型和部分中型网站中非常不错。

但如果是一个企业级的大型应用,用smarty会有诸多不便。不如phplib作为整个系统的一个小巧且功能强大的模块用起来方便~!

其实模板还有一个是很著名,且功能强大的东西,叫smart template。
这个东西偶只做着玩过,没有在实际工作中用过,不敢评价太多。呵呵
bcmath 2003-08-31
  • 打赏
  • 举报
回复
装好smarty了,但是运行他自带的demo文件出错,是怎么回事?Warning: Smarty error: problem writing temporary file 'templates_c\_smarty_cached_paths\3f518bd233a35' in F:\Apache2\htdocs\php\smarty\libs\Smarty.class.php on line 1156

Warning: touch(): Unable to access templates_c\_smarty_cached_paths\index.tpl.php in F:\Apache2\htdocs\php\smarty\libs\core\core.write_compiled_resource.php on line 31

Warning: Smarty error: problem writing temporary file 'templates_c\_smarty_cached_paths\3f518bd24768f' in F:\Apache2\htdocs\php\smarty\libs\Smarty.class.php on line 1156

Warning: touch(): Unable to access templates_c\_smarty_cached_paths\index.tpl.php in F:\Apache2\htdocs\php\smarty\libs\core\core.write_compiled_resource.php on line 31

Warning: Smarty error: problem writing temporary file 'templates_c\_smarty_cached_paths\3f518bd249e24' in F:\Apache2\htdocs\php\smarty\libs\Smarty.class.php on line 1156

Warning: touch(): Unable to access templates_c\_smarty_cached_paths\index.tpl.php in F:\Apache2\htdocs\php\smarty\libs\core\core.write_compiled_resource.php on line 31

Warning: Smarty error: problem writing temporary file 'templates_c\_smarty_cached_paths\3f518bd24fca5' in F:\Apache2\htdocs\php\smarty\libs\Smarty.class.php on line 1156

Warning: touch(): Unable to access templates_c\_smarty_cached_paths\index.tpl.php in F:\Apache2\htdocs\php\smarty\libs\core\core.write_compiled_resource.php on line 31

Warning: Smarty error: problem writing temporary file 'templates_c\_smarty_cached_paths\3f518bd2574c4' in F:\Apache2\htdocs\php\smarty\libs\Smarty.class.php on line 1156

Warning: touch(): Unable to access templates_c\_smarty_cached_paths\index.tpl.php in F:\Apache2\htdocs\php\smarty\libs\core\core.write_compiled_resource.php on line 31

Warning: Smarty error: problem writing temporary file 'templates_c\%%117\%%1172603085\3f518bd25f3d6' in F:\Apache2\htdocs\php\smarty\libs\Smarty.class.php on line 1156

Warning: touch(): Unable to access templates_c\%%117\%%1172603085\index.tpl.php in F:\Apache2\htdocs\php\smarty\libs\core\core.write_compiled_resource.php on line 31

Warning: fetch(templates_c\%%117\%%1172603085\index.tpl.php): failed to open stream: No such file or directory in F:\Apache2\htdocs\php\smarty\libs\Smarty.class.php on line 1323

Warning: fetch(): Failed opening 'templates_c\%%117\%%1172603085\index.tpl.php' for inclusion (include_path='.;c:\php4\pear') in F:\Apache2\htdocs\php\smarty\libs\Smarty.class.php on line 1323

Warning: Smarty error: problem writing temporary file 'templates_c\_smarty_cached_paths\3f518bd260d90' in F:\Apache2\htdocs\php\smarty\libs\Smarty.class.php on line 1156

Warning: touch(): Unable to access templates_c\_smarty_cached_paths\index.tpl.php in F:\Apache2\htdocs\php\smarty\libs\core\core.write_compiled_resource.php on line 31

Warning: Smarty error: problem writing temporary file 'templates_c\_smarty_cached_paths\3f518bd268bd0' in F:\Apache2\htdocs\php\smarty\libs\Smarty.class.php on line 1156

Warning: touch(): Unable to access templates_c\_smarty_cached_paths\index.tpl.php in F:\Apache2\htdocs\php\smarty\libs\core\core.write_compiled_resource.php on line 31

Warning: Smarty error: problem writing temporary file 'templates_c\_smarty_cached_paths\3f518bd26bac3' in F:\Apache2\htdocs\php\smarty\libs\Smarty.class.php on line 1156

Warning: touch(): Unable to access templates_c\_smarty_cached_paths\index.tpl.php in F:\Apache2\htdocs\php\smarty\libs\core\core.write_compiled_resource.php on line 31

Warning: Smarty error: problem writing temporary file 'templates_c\_smarty_cached_paths\3f518bd26eda2' in F:\Apache2\htdocs\php\smarty\libs\Smarty.class.php on line 1156

Warning: touch(): Unable to access templates_c\_smarty_cached_paths\index.tpl.php in F:\Apache2\htdocs\php\smarty\libs\core\core.write_compiled_resource.php on line 31

Warning: Smarty error: problem writing temporary file 'templates_c\%%-10\%%-1005548203\3f518bd27cd0d' in F:\Apache2\htdocs\php\smarty\libs\Smarty.class.php on line 1156

Warning: touch(): Unable to access templates_c\%%-10\%%-1005548203\debug.tpl.php in F:\Apache2\htdocs\php\smarty\libs\core\core.write_compiled_resource.php on line 31

Warning: _include(templates_c\%%-10\%%-1005548203\debug.tpl.php): failed to open stream: No such file or directory in F:\Apache2\htdocs\php\smarty\libs\Smarty.class.php on line 2042

Warning: _include(): Failed opening 'templates_c\%%-10\%%-1005548203\debug.tpl.php' for inclusion (include_path='.;c:\php4\pear') in F:\Apache2\htdocs\php\smarty\libs\Smarty.class.php on line 2042


你用过Ease Template吗?   PHP工程中的模板应用,关于它的好处,我想无论是在实际开发阶段还是上升到设计模式的角度都已经有很多“前辈先哲”"讨论过了。就项目实施而言,在一些中型甚至大型的项目中,有效的将HTML(还有其他文本形式的表现层)和PHP代码分开,不仅在开发阶段可以提高界面设计人员和应用程序编写人员的工作效率,更会给项目的测试和维护带来巨大的便利。 什么是模板技术?   PHP模板发展自Perl的Template。剥开神秘的面纱,模板技术的核心概念简单得令人心跳:要将你的美工页面指定为模板文件,只需将页面中活动的内容部分(如数据库输出,用户交互等)定义成形式为的变量放在模板文件中相应的位置,当用户浏览时,由PHP程序文件打开该模板文件,将模板文件中定义的变量进行替换。当然,替换成对应的数据库输出或者用户交互等动态生成内容。 Ease Template 模板能够改善网站的结构,其特点有: * 可以在几秒钟改变整个站点的外观; * 可以让网站更容易实现多语言; * 抽象程序设计,没有垃圾HTML代码; * 稳定性能初期的强大甚至超越混编代码; * 提供完善的 Debug 平台; * 开发效率地令人惊讶; * 更容易重用模版; * 开源版权保护(保证您的版权不会被侵犯)。 模板技术经过很多年的发展已经演变出各式各样的类型:phplib就效率而言在大量应用的时候效率会降低很多,但是拥有语法简单的优势;Smarty 语法强大效率很高,问题是架构庞大,语法过于复杂。如果你正在设计一个交互式网站,你一定会关注两个主要的问题:美工和程序。这也是一个网站在建设中抛开其内容之后最关键的要素。 通常有两种方式来协调美工和程序之间的关系: 1.先做好美工页面,然后由程序员直接在美工页面的HTML文件中嵌入ASP、JSP、PHP等程序代码。 2.美工和程序同时进行,但这时因为没有页面框架,程序只能先做出部分代码,双方完成后再进行一次美工页面和程序代码的嵌入合成。   在实际的网站建设过程中,由于人员、进度等环境的限制,大家通常会混合使用上面两种协调方式。然而这两种方法都有不足之处: 1. 效率不高。两者协调不好可能产生等待、重复代码调试等现象; 2. 调试不畅。由于程序代码最终需要嵌入在HTML页面中,代码的嵌入、调试、纠错都比较繁琐; 3. 维护不便。一旦美工设计需要修改,如网站改版,那么所有程序和HTML代码混合页面都需要重写。 如果你正在使用PHP程序建设网站,那么恭喜你,PHP模板技术会比较圆满地解决上述问题。 模板应用与结构,以往的开发流程如下:   流水线1:网站设计 -> 切图转为htm -> php工程师写程序 -> 程序套用htm -> 开发结束。 如果存在修改时流程如下:   流水线1:网站设计修改 -> 切图转为htm -> php工程师改程序 -> 程序套用htm -> 修改结束。 采用Ease Template之后将有一些区别性的变化,开发流程如下:   流水线1:php工程师写程序与简单模板 -> 程序测试 -> 开发结束。   流水线2:网站设计 -> 模板工程师修改(Dreamweaver) -> 开发结束。 修改流程如下:   流水线1:网站设计修改 -> 模板工程师修改(Dreamweaver) -> 修改结束。   流水线2:程序员工作被释放出来   Ease Template相对于Smartyphplib提供更简单更高效的方法,甚至可以将数据库运用方法直接写入模板中,这样将无须复杂的数组转换操作。   目前发行的任何一套模板引擎都没有提供开源商业化版权保护。公司开发出的程序,有可能被合作方转卖或盗用。使用Ease Template便不用再为此问题担心,它提供了版权保护设置。开发方启用版权保护设置并对所有程序运行一次后将生成版权保护代码。开发方不需提供程序模板给合作方,程序仍可以独立完整运行。如果合作方需要修改原始模板将非常复杂甚至无法修改。商业版本的程序如果没有模板要修改页面对于任何人都将是非常头疼的工作,而采用Ease Template的开发者则按正常流程即可完成所有的修改工作。   Ease Template 经过多年的发展已经被很多框架所采用,其中比较有名气的当属FleaPHP、ThinkPHP。有些框架直接集成了Ease Template插件,用户选择Ease Template的时候无需担心兼容性以及稳定性。   当Ease Template用户觉得方法过少造成不知如何使用的时候,可以运用{run:}php方法{/run},此操作完全支持系统的所有方法以及用户自己写的方法。   看到这里也许您提出一个问题,那就是Ease Template具有这么多功能那他的速度又能达到什么程度?举个例子:对Ease Template三个引擎进行1万次循环并且载入多个模板情况下的测试结果:替换引擎0.06秒、编译引擎0.04秒、MemCache引擎0.03秒。与各种模板比较,Ease Template编译引擎的速度已经远远超越同类大部分模板,所以您无需为Ease Template的速度担心。   Ease Template 模板技术的基本概念就介绍到这里,请继续关注更加有趣的功能介绍。

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧