Home > Article > Backend Development > strip_tags function usage and examples tutorial_PHP tutorial
Definition and usage
The strip_tags() function removes all HTML, XML and PHP tags.
Grammar
strip_tags(string,allow)
|
illustrate | ||||||
---|---|---|---|---|---|---|---|
string | Required. Specified string check | ||||||
allow | Optional. Specify allowed tags. These tags will not be deleted |
Tips and Instructions NOTE: Comments are always stripped of their HTML. This cannot be changed as an allowed parameter. Example 1
<!--?phpecho strip_tags("Hello <b-->world!");?>
结果为.
Hello world!
再来看一个<strong>strip_tags</strong>函数的例子
<!--?phpecho strip_tags("Hello <b--><i>world!</i>","<b>");?></b>
<b> </b>
<b>Hello <strong>world!</strong></b>