我见过几十个这样的 PHP 片段:
function DB_Quote($string)
{
if (get_magic_quotes_gpc() == true)
{
$string = stripslashes($string);
}
return mysql_real_escape_string($string);
}
如果我打电话会DB_Quote("the (\\) character is cool");
怎样?(感谢jspcal!)
难道我们不应该只在值来自get_magic_quotes_gpc() == true
或超全局时才去除斜线吗?$_GET
$_POST
$_COOKIE