Home  >  Article  >  Backend Development  >  One detail you need to pay attention to when using the php strip_tags() function

One detail you need to pay attention to when using the php strip_tags() function

怪我咯
怪我咯Original
2017-06-08 11:45:194071browse

php The strip_tags() function removes HTML, XML and PHP tags from the string and returns the string after removing the tags. However, there is a detail that needs to be paid attention to when using the php strip_tags() function, that is, when using php strip_tags( ) function, if the HTML tag is incomplete or damaged, more data will be deleted. This article will tell you about the consequences of using the strip_tags() function to remove incomplete HTML tags. Let’s take a look.

Look directly at the example below, the code is as follows:

string

string-1hello

string-2

"; $tags=strip_tags($name,'

'); echo $tags; ?>

Filtering by strip_tags($name, '

'), we may expect to get the following results:

One detail you need to pay attention to when using the php strip_tags() function

But the actual result of running the code is like this

One detail you need to pay attention to when using the php strip_tags() function

What is the reason for this? If you carefully observe the variable $name in the above code, you will find that one tag in the string in $name is incomplete. This is because the strip_tags() function cannot actually verify the integrity of the HTML tag. If the HTML tag is incomplete, it will cause More data is deleted. Therefore, you must pay attention to this when using the php strip_tags() function.

【Recommended related articles】

php remove string tags strip_tags() function example

Use Detailed explanation of php strip_tags() function retaining multiple HTML tag instances

The above is the detailed content of One detail you need to pay attention to when using the php strip_tags() function. 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