Home >Backend Development >PHP Tutorial >In smarty, strip_tags first filters the html tags and then truncate intercepts the article and uses it.

In smarty, strip_tags first filters the html tags and then truncate intercepts the article and uses it.

PHP中文网
PHP中文网Original
2017-06-08 14:19:181200browse

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&#39;, “Blind Woman Gets <span style=”font-family: &amp;amp;”>New Kidney</span> from Dad she Hasn&#39;t Seen in <strong>years</strong>.”); 
$smarty->display(‘index.tpl&#39;);

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&#39;t Seen in <strong>years</strong>. 
Blind Woman Gets New Kidney from Dad she Hasn&#39;t Seen in years.

Article interception:

The code is as follows:

{$article.content|truncate:35:”…”:true}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn