Smarty-变量调节器

来源:互联网 发布:哪个软件淘宝返利最高 编辑:程序博客网 时间:2024/06/07 19:52

变量调节器
1.capitalize  将变量的首字母大写
原变量内容<{$cap|escape:"htmlall"}>
应用后内容<{$cap|capitalize}>
2.count_characters  计算变量的字符个数
不计空格:<{$cap|count_characters}>
计算空格:<{$cap|count_characters:true}>
3.cat  给字符串连接特殊字符
<{$cap|cat:"@#$"}>
4.count_paragraphs   计算段落个数
<{$cap|count_paragraphs}>
5.count_words    计算单词个数
<{$cap|count_words}>
6.count_sentences   计算句子的个数
<{$cap|count_sentences}>
7.利用date_format格式化当前系统的日期/时间
当前系统时间是:<{$smarty.now|date_format}:"%Y-%m-%d %H:%M:%S">  注意:时(H)分(M)秒(S)之间用:分开
8.string_format 格式参数  %d(十进制整数) %x(十六进制整数) %o(八进制整数)  %u(无符号显示)
通过%md格式化一个实数 <{$num|string_format:"%10d"}>
通过%m.n格式化一个实数<{$num|string_format:"%10.2f"}>(四舍五入,保留两位,总长度为10)
通过%e格式化一个实数<{$num|string_format:"%4.2e"}>(科学技术法表示)
9.indent  缩进
<{$cap|indent:4:"$nbsp;"}>
10.upper  转换成大写
<{$cap|upper}>
11.lower  转换成小写
<{$cap|lower}>
12.replace  替换
<{$cap|replace:"php":"java"}>(将php替换成java)
13.truncate  截取字符串
<{$cap|truncate:6:"***":true}>(截取6个字符,后三位是***)
14.spacify  半角变全角

 

 

原创粉丝点击