现在用smarty模板的应该不多,但还是要了解一下它的运作模式。 一、安装 下载Smarty文件放到你们站点中 然后在站点的index.php 文件中的代码: <?php include_once("./Smarty/Smarty.class.php"); //包含smarty类文件 $smarty = new Smarty(); //建立smarty实例对象$smarty $smarty->templates("./templates"); //设置模板目录 $smarty->templates_c("./templates_c"); //设置编译目录 $smarty->cache("./cache"); //缓存目录 $smarty->cache_lifetime = 0; //缓存时间 $smarty->caching = true; //缓存方式 $smarty->left_delimiter = "{#"; $smarty->right_delimiter = "#}"; $smarty->assign("name", "zaocha"); //进行模板变量替换 $smarty->display("index.htm"); //编译并显示位于./templates下的index.htm模板 ?> 二、模板部分 index.htm文件中代码: //包含公共文件 {include file='header.htm'} //输出变量 {$name} //遍历输出数据 {foreach from=$list key=key item=value} 名字:{$value.name} {foreachelse} 没有您所需要的数据! {/foreach} //js、css代码,需要用{literal}标志 {literal} <script>##代码</script> <style>##代码</style> {/literal} //逻辑判断 {if $value.sex == 0} 性别:女 {else} 性别:男 {/if}
相关推荐
PHP Smarty简体中文参考手册(让你更快速掌握PHP Smarty模板引擎,门户型网站常用技术)
Php Smarty 中文版手册 最新版
PHP Smarty 用户登录系统 PHP Smarty 用户登录系统
smarty 语法 配置 标签 方法 使用 自定义方法
资源名称:PHP Smarty中文手册 chm格式内容简介: 早在1999年后期,我们就已经开始为模板引擎写说明文档。在完成这个文档之后,我们开始用c写一个模板引擎,并有希望被包含到php里去。在 撞上了许多的技术难题的同时...
PHP Smarty通过gettext制作多语言版本
php smarty模板开发电子商务网站
PHPSmarty 视频教程PHPSmarty 视频教程PHPSmarty 视频教程PHPSmarty 视频教程
php smarty3.1中文手册
php之smarty入门
phpSmarty模板中文手册, Smarty For Template Designers [模板设计者篇] Smarty For Programmers [程序员篇]
使用smarty模板写的一个音乐网站系统: 整合UC说明: 整合要求:成功安装UCenter和STCMS音乐系统。 整合步骤: 第一步,编辑配置文件: UC的配置文件在/plugins/uc/config.inc.php,只要按照说明配置即可。 ...
php+smarty输出资讯列表,生成html静态
php模版 (smarty)php模版 (smarty)php模版 (smarty)php模版 (smarty)php模版 (smarty)php模版 (smarty)php模版 (smarty)
netbeans的php smarty插件 支持高亮语法 代码提示 netbeans7.0有效
PHP Smarty通过gettext制作多语言版本
php Smarty
PHP Smarty环境下Ajax中文查询的研究.pdf
最新的smarty3.0 以及相应的中文手册,希望这个资源是你所需要的。