免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2294 | 回复: 0
打印 上一主题 下一主题

Smarty ,PHP模板引擎 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-12-21 21:11 |只看该作者 |倒序浏览
什么是smarty?
smarty是一个使用PHP写出来的模板PHP模板引擎,它提供了逻辑与外在内容的分离,简单的讲,
目的就是要使用PHP程序员同美工分离,使用的程序员改变程序的逻辑内容不会影响到美工的页面设计,
美工重新修改页面不会影响到程序的程序逻辑,这在多人合作的项目中显的尤为重要。

安装 Php Smarty Engine
http://smarty.net 下载 php smarty ...
研读 install 或 readme 档案 ...设定 php.ini 安装 Php Smarty Engine
http://smarty.net 下载 php smarty ...
研读 install 或 readme 档案 ...设定 php.ini


安装 Php Smarty Engine
http://smarty.net 下载 php smarty ...
研读 install 或 readme 档案 ...设定 php.ini




c:\AppServ\www\phptest\smarty\ch05\07.php
http://localhost/phptest/smarty/ch05/07.php
1:assign(array ('num1' => $num1, 'num2' => $num2));
8:$smarty->assign('num3', $num3);
9:$smarty->display('ch05/07.tpl.htm');
10:?>
c:\AppServ\www\phptest\smarty\ch05\main.php
1:
c:\AppServ\www\phptest\smarty\class\Template.php
1:template_dir = APP_REAL_PATH . "/templates/";
8: $this->compile_dir = APP_REAL_PATH . "/templates_c/";
9: $this->plugins_dir[] = APP_REAL_PATH . "/plugins/";
10: $this->cache_dir = APP_REAL_PATH . "/cache/";
11: }
12:}
13:?>
c:\AppServ\www\phptest\smarty\config.php
1:
c:\web\smarty_sample\templates\ch05\07.tpl.htm
1:
2:
3:Sample 5-7
4:
5:
6:
7:
8:num1 = {$num1}
9:num2 = {$num2}
10:num1 + num2 = {$num3}
11:num1 + num2 = {$num3|number_format:2}
12:
13:
14:



本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/108609/showart_2127443.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP