为什么所有 $_GET、$_POST 都会自动添加反斜杠?

发布于 2024-10-06 14:03:35 字数 354 浏览 0 评论 0原文

我有一个带有 cPanel/Whm/CentOS 5.5 的 vps,问题是发送到我的服务器的所有参数都被 addslashed,我检查了 PHP 配置,发现所有魔术引号已关闭,我不知道是什么原因造成的。

我的代码非常干净,我知道它的每一点,而且我没有任何 addslashes() 或某种此类函数。我只想按原样接收参数。

URL: test.php?text=blah" ' " 'blah

<?php
echo $_GET["text"]; // Output blah\" \' \" \'blah
?>

怎么关掉这个东西?

谢谢

I have a vps with cPanel/Whm/CentOS 5.5 and the problem is that all parameters sent to my server are being addslashed, I've checked out the PHP configuration and i found out that all the magic quotes are turned off and i don't know what causes this.

My code is so clean and i know every bit of it and i don't have any addslashes() or some sort of these functions. i only want to receive the parameters as they are.

URL: test.php?text=blah" ' " 'blah

<?php
echo $_GET["text"]; // Output blah\" \' \" \'blah
?>

How to turn off this thing?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夜访吸血鬼 2024-10-13 14:03:35

这是 php.ini 中的 magic_quotes_gpc 变量(这是第一个要打开的位置)关闭)。您应该真正检查一下您正在查看正确的文件。

我相信您也可以在 .htaccess 中或在运行时将其关闭。但是,如果您的主机不允许您执行其中任何一项操作,您可以使用以下函数,无论当前设置如何,该函数都会执行此操作。

if(get_magic_quotes_gpc()) {

    $_POST      = array_map('stripslashes_deep', $_POST);
    $_GET       = array_map('stripslashes_deep', $_GET);
    $_COOKIE    = array_map('stripslashes_deep', $_COOKIE);
    $_REQUEST   = array_map('stripslashes_deep', $_REQUEST);
}

function stripslashes_deep($value) {

    return (is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value));
}

It's the magic_quotes_gpc variable in your php.ini (this is the first place to turn it off). You should really check of you are looking at the right file.

You can also turn it off in .htaccess or at runtime I believe. But if your host doesn't won't let you do either of these things you can use the following function that will word regardless of the current setting.

if(get_magic_quotes_gpc()) {

    $_POST      = array_map('stripslashes_deep', $_POST);
    $_GET       = array_map('stripslashes_deep', $_GET);
    $_COOKIE    = array_map('stripslashes_deep', $_COOKIE);
    $_REQUEST   = array_map('stripslashes_deep', $_REQUEST);
}

function stripslashes_deep($value) {

    return (is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value));
}
何以笙箫默 2024-10-13 14:03:35

这是一个(已弃用的)安全功能,称为“魔法引号”,并且可以把它关掉。

It's a (deprecated) security feature called "magic quotes," and it's possible to turn it off.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文