strip_tags() 函数剥去 html、xml 以及 php 的标签。
strip_tags() 函数剥去 html、xml 以及 php 的标签。
代码如下:
<?php echo strip_tags(“Hello <b>world!</b>”); ?>
smarty中可以使用strip_tags去除html标签,包括在< >之间的任何内容。
例如:
index.php:
代码如下:
$smarty = new Smarty; $smarty->assign(‘articleTitle', “Blind Woman Gets <span style=”font-family: &”>New Kidney</span> from Dad she Hasn't Seen in <strong>years</strong>.”); $smarty->display(‘index.tpl');
index.tpl:
代码如下:
{$articleTitle}
{$articleTitle|strip_tags}输出结果:
立即学习“前端免费学习笔记(深入)”;
代码如下:
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.content|truncate:35:”…”:true}
HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号