This article mainly describes the PHP function strip_tags processing string defects of the relevant data, the need for friends can refer to the following
Detailed PHP function strip_tags handling string defect bug
php function Strip_tags () is a commonly used function that strips HTML, XML, and PHP tags from a string. The operation of the string is greatly facilitated, but the strip_tags () function has a defective bug, because strip_tags () cannot verify that the HTML is incomplete or the broken label will result in more data being deleted.
Example:
$str = ' <p>string</p>string<string<b>hello</b><p>string</p> '; Echo strip_tags ($str, ' <p> ');
Output:
<p>string</p>string
Through the Strip_tags function filter <b> tags, I actually want to get the following result:
<p>string</p>string<stringhello<p>string</p>
Causes us not to get the desired result, in fact, because the string of the third string to the left of the angle bracket, the Strip_tags function mistakenly deleted other characters.
Find PHP-related documents found Strip_tags function has a warning: because Strip_tags () cannot actually validate HTML, incomplete or broken labels will result in more data being deleted.
Since you cannot verify the integrity of HTML tags, encountering strings that contain "<" or ">" causes other characters in the string to be mistakenly deleted.