Home  >  Article  >  Backend Development  >  Detailed explanation of using php strip_tags() function to retain multiple HTML tag instances

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

怪我咯
怪我咯Original
2017-06-08 11:44:191969browse

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 = "

我来自PHP中文网

";

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

我来自PHP中文网

"; echo strip_tags($str); ?>

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

我来自PHP中文网

"; echo strip_tags($str,""); ?>

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 ...Multiple tags, you only need to separate multiple tags with spaces and write them to the second parameter of strip_tags:

我来自PHP中文网

"; echo strip_tags($str, "

"); ?>

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!

Statement:
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