|
復(fù)制代碼 代碼如下:
<?php echo strip_tags(“Hello <b>world!</b>”); ?>
smarty中可以使用strip_tags去除html標(biāo)簽,包括在< >之間的任何內(nèi)容。
例如:
index.php:
復(fù)制代碼 代碼如下:
$smarty = new Smarty;
$smarty->assign(‘a(chǎn)rticleTitle', “Blind Woman Gets <span style=”font-family: &amp;”>New Kidney</span> from Dad she Hasn't Seen in <strong>years</strong>.”);
$smarty->display(‘index.tpl');
index.tpl:
復(fù)制代碼 代碼如下:
{$articleTitle}
{$articleTitle|strip_tags}
輸出結(jié)果:
復(fù)制代碼 代碼如下:
Blind Woman Gets <span style=”font-family: helvetica;”>New Kidney</span> from Dad she Hasn't Seen in <strong>years</strong>.
Blind Woman Gets New Kidney from Dad she Hasn't Seen in years.
文章截取:
復(fù)制代碼 代碼如下:
{$article.content|truncate:35:”…”:true}
php技術(shù):smarty中先strip_tags過濾html標(biāo)簽后truncate截取文章運(yùn)用,轉(zhuǎn)載需保留來源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。