smarty变量操作符

capitalize [首字母大写]
count_characters [计算字符数]
cat [连接字符串]
count_paragraphs [计算段落数]
count_sentences [计算句数]
count_words [计算词数]
date_format [时间格式]
default [默认]
escape [转码]
indent[缩进]
lower[小写 ]
nl2br[换行符替换成<br />]
regex_replace[正则替换]
replace[替换]
spacify[插空]
string_format[字符串格式化]
strip[去除(多余空格)]
strip_tags[去除html标签]
truncate[截取]
upper[大写]
wordwrap[行宽约束]

 

{$cook_hotelArr|count} [数组最大下标]

 

{section name=s loop=$stu}

{$stu[s].name}

{sectionelse}

无内容

{/section}

 


$smarty->cache_dir = "/caches/";  //缓存目录
$smarty->caching = true;  //开启缓存,为flase的时侯缓存无效
$smarty->cache_lifetime = 60;  //缓存时间

 

$smarty->display('cache.tpl', cache_id);  //创建带ID的缓存

$smarty->clear_all_cache(); //清除所有缓存
$smarty->clear_cache('index.htm'); //清除index.tpl的缓存
$smarty->clear_cache('index.htm',cache_id); //清除指定id的缓存


index.htm

<div>{insert name="get_time"}</div>

index.php

function insert_get_time(){
      return date("Y-m-d H:m:s");
}

 


literal 数据将被当作文本处理,此时模板将忽略其内部的所有字符信息. 该特性用
于显示有可能包含大括号等字符信息的 javascript 脚本
{literal}
 <script language=javascript> .....
 </script>
{/literal}

 

strip标记中数据的首尾空格和回车. 这样可以保证模板容易理解且不用担心多余的
空格导致问题.
一般放在HTML代码的开始和结束

 

 

**** 同一个域名下的文件缓存处理

比如分站同一个文件,加载时多个参数就可解决

$smarty->display("hotel.htm",$cityId);  

posted on 2011-11-03 15:36 wnguh 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/591wed/archive/2011/11/03/2234608.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值