Home >Backend Development >PHP Tutorial >A brief analysis of a bug in PHP function strip_tags_PHP Tutorial
The PHP function strip_tags provides the function of removing HTML and PHP tags from a string. This function attempts to return the result of the given string str after removing null characters, HTML and PHP tags.
Since strip_tags() cannot actually validate HTML, incomplete or broken tags will cause more data to be deleted.
For example, the following code:
By strip_tags($str, ‘
The actual operation result is this:
This is all because of the red left angle bracket. I checked the PHP documentation and there is a warning:
Since strip_tags() cannot actually validate HTML, incomplete or broken tags will cause more data to be deleted.
Since the correctness of the code cannot be verified before filtering is performed, the code after encountering the tag-related characters “<” or “>” will all hang!