Home  >  Article  >  Backend Development  >  PHP filter unsafe character function_PHP tutorial

PHP filter unsafe character function_PHP tutorial

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

php filter unsafe character function

function uh($str)
{
$farr = array(
"/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 "/(<[^>]*)on[a-zA-Z]+s*=([^>]*>)/isU",//Filter JavaScript on event
);
$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/629755.htmlTechArticlephp filter unsafe character function function uh($str) { $farr = array( /s+/,// Filter excess whitespace/(/?)(script|i?frame|style|html|body|title|link|meta|?|%)([^]*?)/isU,//Filter scr...
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