Instance
Peel the HTML tags from the string:
<?phpecho strip_tags ("Hello <b>world!</b>");? >
Definition and usage
The Strip_tags () function strips the HTML, XML, and PHP tags from the string.
Note: This function always strips HTML comments. This cannot be changed by the Allow parameter.
Note: This function is binary safe.
Grammar
Strip_tags (String,allow)
Parameters |
Describe |
String |
Necessary. Specifies the string to check. |
Allow |
Optional. Specifies the allowable label. These tags are not deleted. |
Technical details
return value: |
Returns the stripped string |
php version: |
update log: |
Since PHP 5.0, this function is binary safe. since PHP 4.3, the function will always strip HTML comments. |
More examples
Example 1
Strip the HTML tags from the string, but allow <b> tags to be used:
<?phpecho strip_tags ("Hello <b><i>world!</i></b>", "<b>");? >
The first parameter is required, which is to remove the source data for HTML and PHP tags, and the second parameter is optional, indicating that no filtering is required.
For example:
<?php$data = ' <a href= '/words?citype=0 > New Thesaurus </a> ' echo $data; Echo ' <br> '; Echo strip_tags ($data);? >
Output |: