Home >Backend Development >PHP Tutorial >PHP strip_tags() function to remove HTML, XML and PHP tags from strings
strip_tags definition and usage
strip_tags() function strips HTML, XML and PHP tags from strings.
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)
Technical details
strip_tags Example 1,
Strip the HTML tags in the string:
<?php echo strip_tags("Hello <b>world!</b>"); ?>
Result
Hello world!,
Example 2
Strip the HTML tags in the string, but allow the tag:
<?php echo strip_tags("Hello <b><i>world!</i></b>","<b>"); ?>
Result
Hello world!
For more PHP strip_tags() function to remove HTML, XML and PHP tags in strings, please pay attention to the PHP Chinese website for related articles!