本文介绍了如果php.ini / .htaccess不可编辑,如何删除魔术引号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些原因,我所有的引号都被转义并显示为\,以前,这是可以的,然后我看了一下phpinfo(),看到我的magic_quotes_gpc已经打开,但是找不到目录/ usr / local / lib /其中php.ini文件是,我无法编辑我的.htaccess文件(获取500内部服务器错误)。

For some reason, all my quotes are being escaped and displayed as \". Previously, it was okay. Then I looked at phpinfo() and saw that my magic_quotes_gpc is turned on. However, I cannot find the directory /usr/local/lib/ where php.ini file is and I cannot edit my .htaccess file (gets 500 Internal Server Error).

我尝试把它放在上面我的脚本文件(包含在所有页面中):

I tried putting this instead on top of my scripts file (which is included in all pages):

if (get_magic_quotes_gpc()) {
    $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
    while (list($key, $val) = each($process)) {
        foreach ($val as $k => $v) {
            unset($process[$key][$k]);
            if (is_array($v)) {
                $process[$key][stripslashes($k)] = $v;
                $process[] = &$process[$key][stripslashes($k)];
            } else {
                $process[$key][stripslashes($k)] = stripslashes($v);
            }
        }
    }
    unset($process);
}

但是,我的网页上的和仍然在其中有反斜杠

But still, the " and ' on my pages still have the backslashes in them.

我做错了什么?

推荐答案

您使用的版本?

如果您使用的版本大于 5.2 ,您可以使用 filter_input() filter_input_array()似乎它忽略了 magic_quotes_gpc -directive并使用原始数据(默认过滤器为 FILTER_UNSAFE_RAW

If you use a version larger than 5.2, than you can use filter_input() or filter_input_array(). It seems that it ignores the setting of the magic_quotes_gpc-directive and uses the raw data (the default filter is FILTER_UNSAFE_RAW)

这篇关于如果php.ini / .htaccess不可编辑,如何删除魔术引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 09:08