使用parse_str时阻止自动添加斜杠

Hac*_*ker 5 php

我的托管服务器上有magic_quotes.所以当我使用parse_str时,它也会为它添加斜杠.所以数据存储为\\'名称..我如何防止这种情况.

小智 5

// Turn off magic_quotes_runtime
if (get_magic_quotes_runtime())
    set_magic_quotes_runtime(0);

// Strip slashes from GET/POST/COOKIE (if magic_quotes_gpc is enabled)
if (get_magic_quotes_gpc())
{
    function stripslashes_array($array)
    {
        return is_array($array) ? array_map('stripslashes_array', $array) : stripslashes($array);
    }

    $_GET = stripslashes_array($_GET);
    $_POST = stripslashes_array($_POST);
    $_COOKIE = stripslashes_array($_COOKIE);
}
Run Code Online (Sandbox Code Playgroud)