- 相關推薦
PHP框架之Smarty中的注釋和截斷功能介紹
這篇文章主要介紹了Smarty中的注釋和截斷功能介紹,這兩個功能都是Smarty中不太常用的功能,但非常實用,需要的朋友可以參考下。更多消息請關注應屆畢業(yè)生網。
注釋
代碼如下:
{* 這是一個單行Smarty注釋 來自于jb51.net,網頁源代碼里看不見*}
{* 這是一個多行
Smarty注釋
并不發(fā)送到瀏覽器
*}
模板注釋由星號包圍,繼而由分隔符包圍,型如:{* 這是一個注釋 *}。Smarty注釋不會在最終模板的輸出中顯示,這點和不同。前者對于在模板中插入內部注釋有用,因為沒有人能看到。;-)
截斷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框架之Smarty中的注釋和截斷功能介紹】相關文章:
PHP中--autoload和Smarty沖突的解決方法07-23
php-smarty模版引擎中的緩存應用04-23
利用PHP模板引擎smarty05-04
PHP及其功能介紹03-28
php中的注釋包括哪些03-07
php中的socket框架性能分析07-17
PHP框架的概念07-11
php中實現(xiàn)回刪功能實例01-26