虽然关闭了magic_quotes 仍然是转义字符串? [英] Although magic_quotes are turned off still escaped strings?

查看:21
本文介绍了虽然关闭了magic_quotes 仍然是转义字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 php.ini 中禁用了 magic_quotes.

I disabled magic_quotes in my php.ini.

但我的表单中仍然有转义字符串.

But I still get escaped strings in my form.

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

Note: I'm running this in a theme in Wordpress.

推荐答案

其实我已经想通了,只是想把我的解决方案留在这里,以防其他人觉得它有用:

I actually already figured this out, just want to leave my solution here in case other people might find it useful:

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

Wordpress automatically escapes all request variables. If magic quotes are turned off, they strip the slashes first, but add them again afterwards.

wp-settings.php 代码片段:

wp-settings.php code piece:

// 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);

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

这篇关于虽然关闭了magic_quotes 仍然是转义字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆