PHP function Strip_tags provides the ability to remove HTML and PHP tags from a string, which attempts to return the result of a given string, STR, that removes null characters, HTML, and PHP tags.
Because Strip_tags () cannot actually validate HTML, incomplete or damaged tags will result in more data being deleted.
For example, the following code:
Copy Code code as follows:
<div>string</div>string <string<b>hello</b><div>string</div>
Through Strip_tags ($str, ' <div> ') filtration, we may expect the following results:
Copy Code code as follows:
<div>string</div>string <stringhello<div>string</div>
and the actual operation result is this:
Copy Code code as follows:
It's all because of Garon's left angle bracket, check the PHP documentation, and have a warning note:
Because Strip_tags () cannot actually validate HTML, incomplete or damaged tags will result in more data being deleted.
Since code correctness cannot be verified before filtering is performed, the code that follows the label-related character "<" or ">" is completely dead!