虽然magic_quotes被关闭仍然逃脱字符串?

Seb*_*itz 5 php wordpress magic-quotes

我在php.ini中禁用了magic_quotes.

但我仍然在表单中获得转义字符串.

注意:我在Wordpress的主题中运行它.

Seb*_*itz 8

我实际上已经想到这一点,只是想留下我的解决方案,以防其他人发现它有用:

Wordpress会自动转义所有请求变量.如果关闭魔术引号,它们会先删除斜杠,但之后再添加它们.

wp-settings.php代码片段:

// If already slashed, strip.
if ( get_magic_quotes_gpc() ) {
$_GET = stripslashes_deep($_GET );
$_POST = stripslashes_deep($_POST );
$_COOKIE = stripslashes_deep($_COOKIE);
}


// Escape with wpdb.
$_GET = add_magic_quotes($_GET );
$_POST = add_magic_quotes($_POST );
$_COOKIE = add_magic_quotes($_COOKIE);
$_SERVER = add_magic_quotes($_SERVER);
Run Code Online (Sandbox Code Playgroud)

资料来源:http://www.wptextads.com/blog/2007/05/19/gpc-magic-quotes-in-wordpress-is-compulsory/