(PHP 4, PHP 5, PHP 7)
strip_tags — 锟斤拷锟街凤拷锟斤拷锟斤拷去锟斤拷 HTML 锟斤拷 PHP 锟斤拷锟�
$str
[, string $allowable_tags
] ) : string
锟矫猴拷锟斤拷锟斤拷锟皆凤拷锟截革拷锟斤拷锟斤拷锟街凤拷锟斤拷 str
去锟斤拷锟斤拷锟街凤拷锟斤拷HTML 锟斤拷 PHP 锟斤拷呛锟侥斤拷锟斤拷锟斤拷锟绞癸拷锟斤拷牒拷锟� fgetss() 一锟斤拷锟侥伙拷锟斤拷去锟斤拷锟斤拷恰锟�
str
锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷
allowable_tags
使锟矫匡拷选锟侥第讹拷锟斤拷锟斤拷锟斤拷指锟斤拷锟斤拷锟斤拷去锟斤拷锟斤拷锟街凤拷锟叫憋拷
Note:
HTML 注锟酵猴拷 PHP 锟斤拷签也锟结被去锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷硬锟斤拷锟诫处锟斤拷模锟斤拷锟斤拷锟斤拷薹锟酵拷锟�
allowable_tags
锟斤拷锟斤拷锟斤拷锟叫改变。
Note:
In PHP 5.3.4 and later, self-closing XHTML tags are ignored and only non-self-closing tags should be used in
allowable_tags
. For example, to allow both <br> and <br/>, you should use:<?php
strip_tags($input, '<br>');
?>
锟斤拷锟截达拷锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷
锟芥本 | 说锟斤拷 |
---|---|
5.3.4 |
strip_tags() ignores self-closing XHTML
tags in
allowable_tags .
|
5.0.0 | strip_tags() 锟斤拷为锟斤拷锟斤拷锟狡帮拷全锟侥★拷 |
Example #1 strip_tags() 锟斤拷锟斤拷
<?php
$text = '<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>';
echo strip_tags($text);
echo "\n";
// 锟斤拷锟斤拷 <p> 锟斤拷 <a>
echo strip_tags($text, '<p><a>');
?>
锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�
Test paragraph. Other text <p>Test paragraph.</p> <a href="#fragment">Other text</a>
锟斤拷锟斤拷 strip_tags() 锟睫凤拷实锟斤拷锟斤拷证 HTML锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟角╋拷锟斤拷锟斤拷赂锟斤拷锟斤拷锟斤拷锟捷憋拷删锟斤拷锟斤拷
锟矫猴拷锟斤拷锟斤拷锟斤拷锟睫革拷 allowable_tags
锟斤拷锟斤拷锟斤拷指锟斤拷锟斤拷锟斤拷锟斤拷锟角碉拷锟轿猴拷锟斤拷锟皆o拷锟斤拷锟斤拷 style 锟斤拷 onmouseover 锟斤拷锟皆o拷锟矫伙拷锟斤拷锟杰伙拷锟斤拷锟结交锟斤拷锟斤拷锟斤拷锟叫讹拷锟斤拷锟斤拷锟斤拷锟斤拷些锟斤拷锟皆o拷锟接讹拷展示锟斤拷锟斤拷锟斤拷锟矫伙拷锟斤拷
Note:
锟斤拷锟斤拷 HTML 锟斤拷签锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟� 1023 锟街斤拷(bytes)锟斤拷锟结被锟斤拷为锟斤拷锟斤拷效锟侥o拷锟斤拷锟斤拷
allowable_tags
锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟侥★拷