Home > Article > Backend Development > Detailed explanation of using php strip_tags() function to retain multiple HTML tag instances
php strip_tags() function removes HTML, XML and PHP tags from the string and returns the string after removing the tags. However, when we need to retain multiple HTML tags, how to use php strip_tags What about the () function? This article introduces how to use the php strip_tags() function to retain multiple HTML tags, let’s take a look.
The method of using the php strip_tags() function to retain multiple HTML tags mainly involves the second parameter of strip_tags. You can use the second parameter to set tags that do not need to be deleted.
How to use
If there is such a string now, the code is as follows
$str = "<p>我来自<b><a href='http://php.cn'>PHP中文网</a></b></p>";
Do not retain any HTML tags, the code is as follows :
Code running output: I come from PHP Chinese website
##Only keep For a tag, you only need to write the string into the second parameter of strip_tags. The code is as follows ");
?>
I am from PHP Chinese website
##To keepand ...Multiple tags, you only need to separate multiple tags with spaces and write them to the second parameter of strip_tags:
");
?>
Code running output:
I am from
##【Recommended related articles】
php Remove string tags strip_tags() function example detailed explanation
One detail you need to pay attention to when using the php strip_tags() function
The above is the detailed content of Detailed explanation of using php strip_tags() function to retain multiple HTML tag instances. For more information, please follow other related articles on the PHP Chinese website!