Home >php教程 >php手册 >php stripslashes()和addslashes()用法

php stripslashes()和addslashes()用法

WBOY
WBOYOriginal
2016-06-13 10:12:011010browse

首先测试 magic_quotes_gpc 是否为 ON, 如果是,则用 array_map() 递归还原转义的数据,下面看用 stripslashes 还原 addslashes 转义后的数据 的简单实现代码

 代码如下 复制代码

if(get_magic_quotes_gpc())
{
    function stripslashes_deep($value)
    {
        $value = is_array($value) ? array_map('stripslashes_deep', $value) : (isset($value) ? stripslashes($value) : null);
        return $value;
    }
 
    $_POST = stripslashes_deep($_POST);
    $_GET = stripslashes_deep($_GET);
    $_COOKIE = stripslashes_deep($_COOKIE);
}
?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn