Use PHP to filter dangerous HTML code_PHP tutorial

WBOY
Release: 2016-07-21 15:51:06
Original
675 people have browsed it

#HTML posted by users, filter dangerous codes
function uh($str)
{
$farr = array(
"/\s+/", //Filter excess whitespace
" /<(\/?)(scrīpt|i?frame|style|html|body|title|link|meta|\?|\%)([^>]*?)>/isU", // Filter "/(<[^>]*)on[a -zA-Z]+\s*=([^>]*>)/isU", //Filter the on event of javascrīpt

);
$tarr = array(
" ",
"<\\1\\2\\3>", //If you want to directly clear unsafe tags, you can leave it blank here
"\\1\\2",
);

$str = preg_replace( $farr,$tarr,$str);
return $str;
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/319187.htmlTechArticle#HTML posted by users, filter dangerous codes functionuh($str) { $farr=array( "/\s+ /",//Filter excess white space"/(\/?)(scrīpt|i?frame|style|html|body|title|link|meta|\?|\%)([^]*?)/isU ...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!