变量调节器后补篇

来源:互联网 发布:淘宝双11报名时间 编辑:程序博客网 时间:2024/05/17 23:38
   今天老师又接着昨天的知识来把变量调节器讲完。
所有的变成小写:lower           将变量字符串小写
       $smarty = new Smarty;
       $smarty->assign('articleTitle', 'Two Convicts Evade Noose, Jury Hung.');
       $smarty->display('index.tpl');
index.tpl:
       {$articleTitle}
       {$articleTitle|lower}
替换:replace       简单的搜索和替换字符串
       $smarty = new Smarty;
       $smarty->assign('articleTitle', "Child's Stool Great for Use in Garden.");
       $smarty->display('index.tpl');
index.tpl:
       {$articleTitle}
       {$articleTitle|replace:"Garden":"Vineyard"}
       {$articleTitle|replace:" ":" "}
所有字符大写:upper       将变量改为大写
       $smarty = new Smarty;
       $smarty->assign('articleTitle', "If Strike isn't Settled Quickly it may Last a While.");
       $smarty->display('index.tpl');
index.tpl:
       {$articleTitle}
       {$articleTitle|upper}
原创粉丝点击