Smarty中的注釋和截斷功能介紹
更新時間:2015年04月09日 09:46:38 投稿:junjie
這篇文章主要介紹了Smarty中的注釋和截斷功能介紹,這兩個功能都是Smarty中不太常用的功能,但非常實用,需要的朋友可以參考下
注釋
復制代碼 代碼如下:
{* 這是一個單行Smarty注釋 來自于jb51.net,網(wǎng)頁源代碼里看不見*}
{* 這是一個多行
Smarty注釋
并不發(fā)送到瀏覽器
*}
模板注釋由星號包圍,繼而由分隔符包圍,型如:{* 這是一個注釋 *}。Smarty注釋不會在最終模板的輸出中顯示,這點和不同。前者對于在模板中插入內部注釋有用,因為沒有人能看到。;-)
http://www.itlearner.com/code/smarty_cn/language.basic.syntax.html
截斷truncate
復制代碼 代碼如下:
$smarty->assign('hxtitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.');
模板為:
復制代碼 代碼如下:
{$hxtitle}
{$hxtitle|truncate}
{$hxtitle|truncate:30}
{$hxtitle|truncate:30:""}
{$hxtitle|truncate:30:"---"}
{$hxtitle|truncate:30:"":true}
{$hxtitle|truncate:30:"...":true}
{$hxtitle|truncate:30:'..':true: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...
Two Sisters Re..ckout Counter.
可以不用在PHP里截取了:http://www.itlearner.com/code/smarty_cn/language.modifier.truncate.html
相關文章
最簡便的MySql數(shù)據(jù)庫備份方法MySQLdump
2008-01-01需要使用php模板的朋友必看的很多個頂級PHP模板引擎比較分析
最近學習php模板技術,找到一篇不錯的關于php模板的分析為了找到一個好的模板引擎,我在互聯(lián)網(wǎng)上進行搜索,目前已經(jīng)整理出了以下名單2008-05-05