《PHP教程:Smarty中的注釋和截斷功能介紹》要點:
本文介紹了PHP教程:Smarty中的注釋和截斷功能介紹,希望對您有用。如果有疑問,可以聯(lián)系我們。
PHP實戰(zhàn)注釋
代碼如下:
{* 這是一個單行Smarty注釋 來自于jb51.net,網(wǎng)頁源代碼里看不見*}
PHP實戰(zhàn)
{* 這是一個多行
?? Smarty注釋
?? 并不發(fā)送到瀏覽器
*}
PHP實戰(zhàn)模板注釋由星號包抄,繼而由分隔符包抄,型如:{* 這是一個注釋 *}.Smarty注釋不會在最終模板的輸出中顯示,這點和不同.前者對于在模板中插入內(nèi)部注釋有用,因為沒有人能看到.;-)
PHP實戰(zhàn)http://www.itlearner.com/code/smarty_cn/language.basic.syntax.html
PHP實戰(zhàn)截斷truncate
代碼如下:
$smarty->assign('hxtitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.');
PHP實戰(zhàn)模板為:
代碼如下:
{$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
維易PHP培訓學院每天發(fā)布《PHP教程:Smarty中的注釋和截斷功能介紹》等實戰(zhàn)技能,PHP、MYSQL、LINUX、APP、JS,CSS全面培養(yǎng)人才。
轉(zhuǎn)載請注明本頁網(wǎng)址:
http://www.snjht.com/jiaocheng/11079.html