I remember writing an article before.
PHP Effective Filter HTML tags, js code, CSS style tags:
Copy Code code as follows:
<?php
$str = Preg_replace ("@<script" (. *?) </script> @is "," ", $str);
$str = Preg_replace ("@<iframe" (. *?) </iframe> @is "," ", $str);
$str = Preg_replace ("@<style" (. *?) </style> @is "," ", $str);
$str = Preg_replace ("@<" (. *?) > @is "," ", $str);
?>
, all regular filters HTML tags, but today it is not good to use them. Why? Is that the tag is escaped. For example, this is <br on the page. But the source file appears like this: "--but we can still handle it, and first compile the contents back.
Copy Code code as follows:
$str = Htmlspecialchars_decode ($STR);
The function of Htmlspecialchars_decode is to convert the source file into a label like <>. And then ":
Copy Code code as follows:
$str = Preg_replace ("/<" (. *?) >/"," ", $str);