#HTML posted by users, filter dangerous codes
function uh($str)
{
$farr = array(
"/\s+/", //Filter excess white space
"/<(\/?)(scrīpt |i?frame|style|html|body|title|link|meta|\?|\%)([^>]*?)>/isU", //Filtering
);
$tarr = array(
" ",
"<\\1\\2\\3>", //If To directly clear unsafe tags, you can leave it blank here
"\\1\\2",
);
$str = preg_replace( $farr,$tarr,$str);
return $str;
}
The above has introduced the HTML code converter function that uses PHP to filter dangerous HTML codes, including the content of the HTML code converter. I hope it will be helpful to friends who are interested in PHP tutorials.