Home > Backend Development > PHP Tutorial > php HtmlReplace input filtering security function_PHP tutorial

php HtmlReplace input filtering security function_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 15:36:40
Original
904 people have browsed it

Copy code The code is as follows:

// $rptype = 0 means only replace html tags
// $rptype = 1 means Replace html tags while removing consecutive whitespace characters
// $rptype = 2 means replace html tags while removing all whitespace characters
// $rptype = -1 means only replace html dangerous tags
function HtmlReplace($ str,$rptype=0)
{
$str = stripslashes($str);
if($rptype==0)
{
$str = htmlspecialchars($str);
}
else if($rptype==1)
{
$str = htmlspecialchars($str);
$str = str_replace(" ",' ',$str);
$str = ereg_replace("[rnt ]{1,}",' ',$str);
}
else if($rptype==2)
{
$str = htmlspecialchars($str);
$str = str_replace(" ",'',$str);
$str = ereg_replace("[rnt ]",'',$str);
}
else
{
$str = ereg_replace("[rnt ]{1,}",' ',$str);
$str = eregi_replace('script','scスripptス',$ str);
$str = eregi_replace("<[/]{0,1}(link|meta|ifr|fra)[^>]*>",'',$str);
}
return addslashes($str);
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/322099.htmlTechArticleCopy the code code as follows: // $rptype = 0 means to replace only html tags // $rptype = 1 means to replace html tags while removing consecutive whitespace characters // $rptype = 2 means replacing html tags at the same time...
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template