Home  >  Article  >  Backend Development  >  php stripslashes()和addslashes()用法_PHP教程

php stripslashes()和addslashes()用法_PHP教程

WBOY
WBOYOriginal
2016-07-13 17:10:15960browse

首先测试 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);
}
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/629684.htmlTechArticle首先测试 magic_quotes_gpc 是否为 ON, 如果是,则用 array_map() 递归还原转义的数据,下面看用 stripslashes 还原 addslashes 转义后的数据 的简单实现...
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