smarty初体验
来源:互联网 发布:linux cdn 测试 编辑:程序博客网 时间:2024/06/14 08:38
终于接触到smarty了啊。原来框架是这样的。我个人觉得其实就是一个类,感谢前辈编写的日子。他们的辛苦造就了我们的幸福。我们使用就OK了。其实和织梦差不多的用法啊。其实smarty对PHP来说真的是革命性的啊。他把前端表现和后台处理PHP做到了分离,并且进行了精简,而且在前台语言标签里可以使用变量。
现在我来巩固一下第一天学到的知识,
$tpl->template_dir = "work/templates"; //设置所有模板文件存放的目录
$tpl->compile_dir = "work/templates_c"; //设置所有编译过的模板文件存放的目录
$tpl->config_dir = "work/configs"; //设置模板中特殊配置文件存放的目录
$tpl->cache_dir = "work/cache"; //设置存放Smarty缓存文件的目录
$tpl->caching=0; //设置开启Smarty缓存模板功能
$tpl->cache_lifetime=60*60*5; //设置缓存有效时间段的长度为5小时
$tpl->left_delimiter = '['; //设置模板语言中的左结束符
$tpl->right_delimiter = ']'; //设置模板语言中的右结束符
编译后的文件会在templates_c文件中$smarty->assign(“title”,“标题"); 在PHP文件中
{$title}在HTML文件中
$smarty->display("index.tpl")
显示出来;
{* 这里显示的文字是smarty中的注释 *}
数组类型变量,也是调用模板内的assign函数分配值
{$test[0].phone}
3、从配置文件中读取变量的值并输出
<body bgcolor="{#bgcolor#}">
这是我第一天学习smarty主要的内容。
- smarty初体验
- smarty缓存初解
- Smarty
- Smarty
- smarty
- smarty
- Smarty
- smarty
- smarty
- smarty
- smarty
- smarty
- smarty、
- smarty
- smarty
- Smarty
- Smarty
- smarty
- hdu 4009(最小树形图)
- HDU1060 数学方法实现超大数计算
- Milking Cows 挤牛奶
- 用java字节码解释i++和++i
- 什么是 C# 分部类(partia)
- smarty初体验
- attachEvent使用简介
- 三张经典图片展示Data Guard主备之间日志传输及恢复
- 网络课的笔记
- java 基础
- linux网络编程笔记1
- 数据流操作(一)
- 基本的几个排序
- new与delete