欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

解析smarty 截取字符串函數(shù) truncate的用法介紹

 更新時間:2013年06月20日 12:01:32   作者:  
本篇文章是對smarty 截取字符串函數(shù) truncate的用法進行了詳細的分析介紹,需要的朋友參考下
smarty truncate 截取字符串
從字符串開始處截取某長度的字符,默認的長度為80
指定第二個參數(shù)作為截取字符串的長度
默認情況下,smarty會截取到一個詞的末尾,
如果需要精確到截取多少個字符可以使用第三個參數(shù),將其設為”true”
具體用法如下:
復制代碼 代碼如下:

//index.php $smarty = new Smarty;
$smarty->assign('articleTitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.');
$smarty->display('index.tpl');
//index.tpl
{$articleTitle}
{$articleTitle|truncate}
{$articleTitle|truncate:30}
{$articleTitle|truncate:30:""}
{$articleTitle|truncate:30:"---"}
{$articleTitle|truncate:30:"":true}
{$articleTitle|truncate:30:"...":true}

輸出結果:
Two Sisters Reunite after Eighteen Years at Checkout Counter.
Two Sisters Reunite after Eighteen Years at Checkout Counter.
Two Sisters Reunite after…
Two Sisters Reunite after
Two Sisters Reunite after—
Two Sisters Reunite after Eigh
Two Sisters Reunite after E…

相關文章

最新評論