较深度地递归转义过滤

收藏的一个函数:

function addslashes_deep($value){
	if (empty($value)){
		return $value;
	}
	else{
		return is_array($value) ? array_map('addslashes_deep', $value) : addslashes($value);
	}
}

后面就这样处理接收来的数据:

if (!get_magic_quotes_gpc()){
    if (!empty($_GET)){
        $_GET  = addslashes_deep($_GET);
    }
    if (!empty($_POST)){
        $_POST = addslashes_deep($_POST);
    }
    $_COOKIE   = addslashes_deep($_COOKIE);
    $_REQUEST  = addslashes_deep($_REQUEST);
}

不过说php6要将get_magic_quotes_gpc去掉,手册上面对该值的配置已经不推荐了。

原文地址:https://www.cnblogs.com/ppoo24/p/1875771.html