smarty的基本语法
1.smarty的注释:{*content*}
2.smarty输出变量的值
a.当变量是数组或者字符串时,如下输出:
变量的赋值与输出
$smarty->assign('articletitle','文章标题');
{$articletitle}
数组的赋值与输出
$arr=array('content'=>"smarty学习",'author'=>"小明");
$smarty->assign('arr',$arr);
{$arr.content}{$arr.author}
3.变量调节器
a.对输出变量进行首字母的大写转换使用capitalize:{$articletitle|capitalize}
b.对输出内容进行字符串的连接使用cat
{$articletitle|cat:"i love my life"}
c.对输出日期进行格式化
{$time|date_format:"%H:%M:%S"}格式化输出时分秒
{$time|date_format:"%B %e %Y"}格式化输出月日年
d.url转码
{$url|escape:"url"}
e.输出字符串大小写转换
{$articletile|upper}
{$articletile|lower}
f.输出字符串换行输出
{$content|nl2br}
原文链接:https://blog.csdn.net/living_ren/article/details/78277779
本站声明:网站内容来源于网络,如有侵权,请联系我们,我们将及时处理。
还没有人抢沙发呢~