Home >Backend Development >PHP Tutorial >PHP filter unsafe html program_PHP tutorial

PHP filter unsafe html program_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:09:09783browse

php filter html php filter html code filter html asp filter html filter html code filter html tag asp filter html code

function uh($str)
{

$tarr = array(
" ",
" "\1\2",
);


$farr = array(
"/s+/", "/s+/", "/s+/" //Filter excess whitespace
"/<(/?)(script|i?frame|style|html|body|title|link|meta|?|%)([^>]*?)>/isU", //Filter < ;script and other code that may introduce malicious content or maliciously change the display layout. If you don’t need to insert flash, etc., you can also add "/(& Lt; [^& gt;]*) on [a-za-z]+s*= ([^& gt;]*& gt;) // // filter the on event of javascript
                     
);
 
$str = preg_replace( $farr,$tarr,$str);
Return $str;
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/629760.htmlTechArticlephp filter html php filter html code filter html asp filter html filter html code filter html tag asp filter html code functionuh( $str) { $tarr=array( , <\1\2\3>,//If you want to directly...
Statement:
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