Home >Backend Development >PHP Problem >How to clear tags in php
You can use the built-in "strip_tags" function in php to clear tags. This function always strips HTML comments. Its syntax is "strip_tags(string,allow)". The parameter "string" represents the character to be checked. string.
Recommended: "PHP Tutorial"
strip_tags definition and usage
# The ##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. Syntaxstrip_tags(string,allow)Parameters string Required. Specifies the string to check. allow Optional. Specifies allowed tags. These tags will not be deleted. Return value: Returns the stripped string. PHP Version: 4 Change Log: Since PHP 5.0, this function is binary safe. Since PHP 4.3, this function always strips HTML comments. Example Strip the HTML tags in the string, but allow the tag:
<?php echo strip_tags("Hello <b><i>world!</i></b>","<b>"); ?>Run result:
The above is the detailed content of How to clear tags in php. For more information, please follow other related articles on the PHP Chinese website!