收藏的一个函数:

 

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去掉,手册上面对该值的配置已经不推荐了。

 

posted on 2010-11-12 16:02  重生  阅读(283)  评论(0编辑  收藏  举报