Home >Backend Development >PHP Tutorial >In smarty, strip_tags first filters the html tags and then truncate intercepts the article and uses it.
strip_tags() function strips HTML, XML and PHP tags.
strip_tags() function strips HTML, XML and PHP tags.
The code is as follows:
<?php echo strip_tags(“Hello <b>world!</b>”); ?>
You can use strip_tags in smarty to remove html tags, including any content between 6d267e5fab17ea8bc578f9e7e5e1570b.
For example:
index.php:
The code is as follows:
$smarty = new Smarty; $smarty->assign(‘articleTitle', “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:
The code is as follows:
{$articleTitle} {$articleTitle|strip_tags}
Output result:
The code is as follows:
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.
Article interception:
The code is as follows:
{$article.content|truncate:35:”…”:true}