strip_tags
这会删除 HTML 标记,基本上会删除 <
和 >
之间的所有内容。
基本用法
参数
参数位置 | 类型 | 必需 | 默认 | 描述 |
---|---|---|---|---|
1 | 布尔值 | 否 | 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} {* same as {$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.
另请参见 replace
和 regex_replace
。