Detailed explanation of using php strip_tags() function to retain multiple HTML tag instances

怪我咯
Release: 2023-03-08 06:32:02
Original
2055 people have browsed it

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=&#39;http://php.cn&#39;>PHP中文网</a></b></p>";
Copy after login

Do not retain any HTML tags, the code is as follows :

Copy after login

Code running output: I come from PHP Chinese website

Detailed explanation of using php strip_tags() function to retain multiple HTML tag instances

##Only keep For a tag, you only need to write the string into the second parameter of strip_tags. The code is as follows

Output when the code is run:

I am from PHP Chinese website

Detailed explanation of using php strip_tags() function to retain multiple HTML tag instances

##To keep

and < b>...Multiple tags, you only need to separate multiple tags with spaces and write them to the second parameter of strip_tags:

 ");
?>
Copy after login
Code running output:

I am from

Detailed explanation of using php strip_tags() function to retain multiple HTML tag instances##【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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!