The following is the program code: Copy the code The code is as follows: function uhtml($str) { $farr = array( "/s+/", //Filter excess blanks//Filter and other codes that may introduce malicious content or maliciously change the display layout. If you do not need to insert flash, etc., you can also add filtering of <object><br>"/<(/?)(script|i?frame|style |html|body|title|link|meta|?|%)([^>]*?)>/isU", <br>"/(<[^>]*)on[a-zA-Z ]+s*=([^>]*>)/isU",//Filter the on event of javascript <br>); <br>$tarr = array( <br>" ", <br>"<123>",//If you want Directly clear unsafe tags, you can leave them blank here <br>"12", <br>); <br>$str = preg_replace( $farr,$tarr,$str); <br>return $str; <br>} <br></p> <p> The above introduces hktm php filtering dangerous html code, including hktm content. I hope it will be helpful to friends who are interested in PHP tutorials. </p> <p> </p>