Heim  >  Artikel  >  Backend-Entwicklung  >  smarty变量操作符总结_PHP教程

smarty变量操作符总结_PHP教程

WBOY
WBOYOriginal
2016-07-13 10:31:05843Durchsuche

smarty 常用的变量操作符总结。

capitalize [首字母大写]
count_characters [计算字符数]
cat [连接字符串]
count_paragraphs [计算段落数]
count_sentences [计算句数]
count_words [计算词数]
date_format [时间格式]
default [默认]
escape [转码]
indent[缩进]
lower[小写 ]
nl2br[换行符替换成
]
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

{insert name="get_time"}

index.php

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

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

{literal}

{/literal}

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

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

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

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

您可能感兴趣的文章

  • Smarty模板变量操作符总结
  • smarty模板中使用php函数以及smarty模板中如何对一个变量使用多个函数
  • smarty模板保留变量总结
  • smarty include file 使用变量的方法
  • smarty循环操作
  • 对用户传入的变量进行转义操作处理,摘自ecshop
  • javascript获取鼠标当前位置(兼容IE和firefox)
  • 用PHP函数memory_get_usage获取当前PHP内存消耗量以实现程序的性能优化

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/764163.htmlTechArticlesmarty 常用的变量操作符总结。 capitalize [首字母大写] count_characters [计算字符数] cat [连接字符串] count_paragraphs [计算段落数] count_sentences [计...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn