Skip to content

strip_tags

这个修饰符用于去除 HTML 标记,即位于 <> 之间的内容。

基本用法

{$myVar|strip_tags}

参数

参数位置 类型 必需 默认值 描述
1 bool TRUE 决定是否用空格或空字符串替换标记。

示例

<?php

$smarty->assign('articleTitle',
                "Blind Woman Gets <font face=\"helvetica\">New
Kidney</font> from Dad she Hasn't Seen in <b>years</b>."
               );

模板如下:

{$articleTitle}
{$articleTitle|strip_tags} {* 与 {$articleTitle|strip_tags:true} 相同 *}
{$articleTitle|strip_tags:false}

输出结果如下:

Blind Woman Gets <font face="helvetica">New Kidney</font> from Dad she Hasn't
Seen in <b>years</b>. Blind Woman Gets New Kidney from Dad she Hasn't Seen in
years . Blind Woman Gets New Kidney from Dad she Hasn't Seen in years.

另请参阅 replaceregex_replace