PHP strip_tags () function
Examples
Stripped string HTML tags:
<?php
echo strip_tags("Hello <b>world!</b>");
?>
echo strip_tags("Hello <b>world!</b>");
?>
Running instance »
Definition and Usage
strip_tags () function stripped string HTML, XML and PHP tags.
Note: This function is always stripped HTML comments.This point can not be changed by the parameters allow.
Note: This function is binary safe.
grammar
strip_tags( string,allow )
参数 | 描述 |
---|---|
string | 必需。规定要检查的字符串。 |
allow | 可选。规定允许的标签。这些标签不会被删除。 |
technical details
return value: | Returns the stripped string. |
---|---|
PHP version: | 4+ |
Update log: | Since PHP 5.0 onwards, the function is binary safe. Since PHP 4.3, the function will always peeling HTML comments. |
More examples
Example 1
Stripped string HTML tags, but it allows the use of <b> tag:
<?php
echo strip_tags("Hello <b><i>world!</i></b>","<b>");
?>
echo strip_tags("Hello <b><i>world!</i></b>","<b>");
?>
Running instance »
PHP String Reference