#HTML posted by users, filter dangerous code Copy code The code is as follows: function uh($str) { $farr = array( "/s+/", //Filter excess whitespace "/<(/?)(scripti?framestylehtmlbodytitlelinkmeta?%)([^>]*?)>/isU", //Filter "/(<[^>]*)on[a-zA-Z]+s*=([^>]*>) /isU", //Filter javascript on events<br>); <br>$tarr = array( <br>" ", <br>"<\1\2\3>", //If you want to directly clear unsafe tags, you can leave them here Empty <br>"\1\2", <br>); <br>$str = preg_replace( $farr,$tarr,$str); <br>return $str; <br>} <br></p> <p> The above introduces the html color code PHP filter dangerous html code, including the content of html color code. I hope it will be helpful to friends who are interested in PHP tutorials. </p> <p> </p>