php防注入

服务器:

设置magic_quotes_gpc()为on,display_errors设置为off

传过来的数据

如果是id型,可以用intval()转化成整数类型

如果是字符型,可以用addslashes()过滤一下,然后过滤"_"和"%"

$str = addslashes($str);

$str = str_replace("_", "\_", $str);

$str = str_replace("%", "\%", $str);

密码采取md5加密也可以防止注入

原文地址:https://www.cnblogs.com/hell0x/p/5952061.html