由于5.3去掉了get_magic_quotes_gpc函数,所以自己写了一个防注入的函数。
function sql_injection($content){ if (is_array($content)){ foreach ($content as $key=>$value){ if (is_array($value)){ foreach ($value as $k=>$val){ if (!get_magic_quotes_gpc()){ $val = addslashes($val); } $tmp = str_replace( " ", "", $val); $content[$key][$k] = str_replace( "%", "", $tmp); } } else { if (!get_magic_quotes_gpc()){ $value = addslashes($value); } $tmp = str_replace( " ", "", $value); $content[$key] = str_replace( "%", "", $tmp); } } } else { if (!get_magic_quotes_gpc()){ $content = addslashes($content); } $tmp = str_replace( " ", "", $content); $content = str_replace( "%", "", $tmp); } return $content; } $_POST=sql_injection($_POST); $_GET=sql_injection($_GET);