Example
Strip the HTML tags in the string:
<?php echo strip_tags("Hello <b>world!</b>"); ?>
Definition and usage
strip_tags() function strips the HTML tags in the string HTML, XML and PHP tags.
Comments: This function always strips HTML comments. This cannot be changed via the allow parameter.
Note: This function is binary safe.
Syntax
strip_tags(string,allow)
Parameters | Description |
string | Required. Specifies the string to check. |
allow | Optional. Specifies allowed tags. These tags will not be deleted. |
Technical details
Return value: | Returns the stripped string |
PHP Version: | 4+ |
##Change Log: | Since PHP 5.0 From now on, this function is binary safe.Since PHP 4.3, this function always strips HTML comments. |
<?php echo strip_tags("Hello <b><i>world!</i></b>","<b>"); ?>
<?php $data = '<a href="/words?citype=0">新词库</a>'; echo $data; echo "<br>"; echo strip_tags($data); ?>
The above is the detailed content of PHP strips the html, xml and php tags in the string function strip_tags(). For more information, please follow other related articles on the PHP Chinese website!