PHP filter unsafe character function_PHP tutorial

WBOY
Release: 2016-07-13 17:09:19
Original
746 people have browsed it

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...
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!