php防sql注入函数

function clean($str)
{
 $str=trim($str);
 $str=strip_tags($str);
 $str=stripslashes($str);
 $str=addslashes($str);
 $str=rawurldecode($str);
 $str=quotemeta($str);
 $str=htmlspecialchars($str);
 $str=preg_replace("//+|/*|/`|//|/-|/$|/#|/^|/!|/@|/%|/&|/~|/^|/[|/]|/'|/"/", "", $str);//去除特殊符号+*`/-$#^~!@#$%&[]'"
 $str=preg_replace("//s/", "", $str);//去除空格、换行符、制表符
 return $str;
}

转自网络

posted on 2016-04-20 19:05  飞羽哥哥  阅读(709)  评论(0编辑  收藏  举报

导航