Smarty变量调节器的使用
2012-04-25 17:20
316 查看
$str = 'how Are you'; $smarty->assign('str', $str); $title = "\nbbbbbb。bbbb\n1111111\nbbbbbbbb\n222.\t22.22"; $smarty->assign('title',$title); $name = "who are \n you?"; $smarty->assign('name',$name); $address = "<center>I'm center</center><sm>ddddddd</sm>"; $smarty->assign('address',$address); $leg = "1a2 admin b3c4d5e6g7h8i9j"; $smarty->assign('leg',$leg); $file = "hi who are you where are from"; $smarty->assign('file',$file); $num = 123.4567; $smarty->assign('num',$num); $content = "hit me <a href='#'>this is a test</a><?c=admin&a=input>aaa@admin.com"; $smarty->assign('content',$content); $smarty->display('index.html'); //显示index.html
html
<{$str}><br> <{$str|capitalize}><{*首字母大写*}><br> <{$str|upper}><{*全部大写*}><br> <{$str|lower}><{*全部小写*}><br> <{$str|lower|upper}><{*全部大写,调节从左至右*}><br> <{$str|count_characters}><{*统计字符的个数*}><br> <{$str|count_characters:true}><{*统计字符的个数,包括空格*}><br> <{$str|cat:"??????"}><{*连接到变量的值后面*}><br><br> <{$title|count_paragraphs}><{*统计变量中段落的个数,即相邻\n或\r的会算为一个*}><br> <{$title|count_sentences}><{*统计变量中句子的个数*}><br> <{$title|count_words}><{*统计变量中单词的个数*}><br><br> <{$smarty.now|date_format:"%Y-%m-%d %p %H:%M:%S week:%W"}><{*当前时间2012-04-25 AM 08:20:17 week:17*}><br><>br <{$user|default:"null"}><{*如果变量为空或者不存在时,输出默认的值,即default的值*}><br><br> <{$name}><br> <{$name|indent}><br> <{$name|indent:10}><br> <{$name|indent:1:"\t"}><br><br> <{$name|regex_replace:"/[\r\n\t]/":"string"}><{*正则替换*}><br><br> <{$name|replace:"who":"where"}><{*替换*}><br><br> <{$name|spacify:"!"}><{*在字符之间插入字符*}><br><br> <{$name|strip}><{*用空格或指定字符替换所有重复空格、换行、制表符*}><br> <{$name|strip:" "}><br><br> <{$address}><br> <{$address|strip_tags}><{*去掉<>标签及中间的内容*}><br><br> <{$leg|truncate}><{*字符串截取,默认80个字符*}><br> <{$leg|truncate:10}><{*字符串截取,前10个,包括...三个字符*}><br> <{$leg|truncate:10:""}><{*字符串截取,前10个字符,不用...代替后面的内容*}><br> <{$leg|truncate:10:"---"}><{*字符串截取,前10个字符,以单词结束,用---代替后面的内容*}><br> <{$leg|truncate:10:"...":true}><{*字符串截取,前10个字符,精确个数,用...代替后面的内容*}><br> <{$leg|truncate:10:"":true}><{*字符串截取,前10个字符,不用...代替后面的内容*}><br><br> <{$file}><br> <{$file|wordwrap:10}><{*10字符为一行*}><br> <{$file|wordwrap:10:"<br>\n"}><{*10字符为一行*}><br> <{$file|wordwrap:10:"\n":true}><{*10字符为一行*}><br><br> <{$num}><br> <{$num|string_format:"%.2f"}><{*取两位小数,四舍五入*}><br> <{$num|string_format:"%d"}><{*取整*}><br><br> <{$content}><br> <{$content|escape}><br> <{$content|escape:"html"}><br> <{$content|escape:"htmlall"}><br> <{$content|escape:"url"}><br> <{$content|escape:"quotes"}><br> <{$content|escape:"hex"}><br> <{$content|escape:"hexentity"}><br> <{$content|escape:"javascript"}><br>
变量调节器,可以组合使用,来达到显示的效果,用"|"分隔,从左到右执行
结果:
相关文章推荐
- php学习笔记(三十七)smarty中的变量调节器使用
- Smarty变量调节器的使用
- smarty使用变量与变量调节器
- smarty之变量调节器
- smarty模板中使用get、post、request、cookies、session变量的方法
- smarty模板变量调节器
- smarty的使用变量
- Smarty中变量调节器
- Smarty:变量调节器&插件&缓存
- Smarty模板技术-变量调节器
- 使用Smarty的相关注意事项及访问变量的几种方式
- smarty学习——变量调节器(过滤器)
- 三、smarty--变量调节器(修改器)
- Smarty变量调节器
- PHP 中使用 Smarty 之二:配置文件在模板变量中的使用
- smarty中变量调节器
- smarty3 变量调节器Variable Modifiers(2)
- Smarty变量调节器2
- SMARTY模板中如何使用get,post,request,cookies,session,server变量
- php学习笔记_Smarty变量调节器以及如何自定义