PHP有无必要运用Smarty呢?
Jun 13, 2016 pm 01:08 PM
gt
lt
nbsp
smarty
PHP有无必要使用Smarty呢??
使用Smarty是可以处理很多东西,但是近来本人相当的困惑,有无这个必要呢????它提供了很多页面的模板指令,但是我在开发的过程中实际上都很少用到... 每次都挂上这个东西是不是浪费呢??
?
比如这个生成RSS的代码,使用原生的PHP相当的简单
<?php header("Content-Type:text/xml"); echo '<?xml version="1.0" encoding="UTF-8"?>' //这后面不能加换行符; ?> <rss version="2.0"> <channel> <title>Module Action Menu</title> <link>appstore/contenter/action-menu/exep-menu.xml</link> <description> 每个菜单模块下有多个菜单链接,每个连接对应此文件中的一个item项. 这个文件必须放在外部访问不到的地方,客户端使用一个统一的控制器来获取相应的这个文件. 此文件由PHP程序动态生成,并使用unicode编码,客户端获取后,反解析显示. 为了提高效率,在后期可以生成缓存文件. </description> <language>zh-cn</language> <copyright> Copyright ? 2006 Beijing Extreme Club. All Rights Reserved </copyright> <pubDate></pubDate> <lastBuildDate></lastBuildDate> <docs>http://www.beijingextreme.com.cn/rss</docs> <generator>iamsese vb2005xu</generator> <managingEditor>vb2005xu</managingEditor> <webMaster>trcn17@gmail.com</webMaster> <?php $menu_text = array() ; $menu_text['zh'] = array( '地理资讯','历史资讯','宗教', '传说','气候','高原反应', '西藏推荐行程','西藏寺庙','名山险峰', '地图','相册' ) ; $menu_text['ru'] = array( 'Географическая справка','Историческая справка','Религия', 'Мифы','Климат','Горная болезнь', 'Рекомендуемые маршруты в Тибете','Монастыри Тибета','Достопримечательности', 'Карты','Фотогалерея' ) ; $forwardCtl_Tibet = "f.php?action=" ; $forwardCtl_Tibet = str_ireplace('&','#p#',$forwardCtl_Tibet); $menu_href = array( "{$forwardCtl_Tibet}dl","{$forwardCtl_Tibet}lsh","{$forwardCtl_Tibet}zj", "{$forwardCtl_Tibet}chsh","{$forwardCtl_Tibet}qh","{$forwardCtl_Tibet}gyfy", "{$forwardCtl_Tibet}tjlch","{$forwardCtl_Tibet}xzsm","{$forwardCtl_Tibet}mshxf", "{$forwardCtl_Tibet}dt","{$forwardCtl_Tibet}xc" ) ; for ($i=0;$i<count($menu_text['ru']);$i++){ ?> <item> <title><?php echo $menu_text['ru'][$i] ?></title> <link><?php echo $menu_href[$i] ?></link> <description>这里要注意的是注意url参数连接字符的置换,这里使用#p#来代替</description> <pubDate><?php echo date('Y-m-d H:i:s') ?></pubDate> <guid><?php echo $i+1 ?></guid> <t><?php echo $menu_text['zh'][$i] ?></t> </item> <?php } ?> </channel> </rss>
Copy after login
?
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

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Solution: Your organization requires you to change your PIN

How to adjust window border settings on Windows 11: Change color and size

How to change title bar color on Windows 11?

How to enable or disable taskbar thumbnail previews on Windows 11

OOBELANGUAGE Error Problems in Windows 11/10 Repair

What are the differences between Huawei GT3 Pro and GT4?

10 Ways to Adjust Brightness on Windows 11

像RSS这种东西我是觉得直接用php也挺好的
当然用php也可以做到
用php做需要精心设计文件组织,用smarty可以简化不少
何况smarty还可以很方便的静态化页面,也算是一个不错的功能
不过一般如果很小的项目似乎也不能从smarty得到多大的好处
就我的感受而言,smarty存在的目的就是为了将VC分离,其本身自带的那么多控制流程走向的东西,大概本意仅是用在实在得用的时候做为补充方法.一但在模板中用太多控制条件,那跟直接嵌入PHP也就没什么区别了.两相比较我更喜欢再轻型一点的smarttemplate.
就我的感受而言,smarty存在的目的就是为了将VC分离,其本身自带的那么多控制流程走向的东西,大概本意仅是用在实在得用的时候做为补充方法.一但在模板中用太多控制条件,那跟直接嵌入PHP也就没什么区别了.两相比较我更喜欢再轻型一点的smarttemplate.
恩,基本上感觉是和你一样的,判断条件多的时候,if else不胜其烦。
轻量级的就够了。
如果你只知道代替,那我想strtr也许更方便
就我的感受而言,smarty存在的目的就是为了将VC分离,其本身自带的那么多控制流程走向的东西,大概本意仅是用在实在得用的时候做为补充方法.一但在模板中用太多控制条件,那跟直接嵌入PHP也就没什么区别了.两相比较我更喜欢再轻型一点的smarttemplate.
恩,基本上感觉是和你一样的,判断条件多的时候,if else不胜其烦。
轻量级的就够了。
不是吧?smarty还有缓存的功能啊!
就我的感受而言,smarty存在的目的就是为了将VC分离,其本身自带的那么多控制流程走向的东西,大概本意仅是用在实在得用的时候做为补充方法.一但在模板中用太多控制条件,那跟直接嵌入PHP也就没什么区别了.两相比较我更喜欢再轻型一点的smarttemplate.
恩,基本上感觉是和你一样的,判断条件多的时候,if else不胜其烦。
轻量级的就够了。
不是吧?smarty还有缓存的功能啊!
有缓存功能的多了,又不止只有smarty.
发几个争论帖子观摩一下吧
http://bbs.phpchina.com/viewthread.php?tid=110467
http://bbs.phpchina.com/viewthread.php?tid=67407
http://bbs.phpchina.com/viewthread.php?tid=67221