首页 > php开发 > PHP5下$_SERVER变量不再受magic_quotes_gpc保护

PHP5下$_SERVER变量不再受magic_quotes_gpc保护

在php5的环境中我们的$_SERVER变量将不再受magic_quotes_gpc的保护,至于程序该如何加强自己的安全性,下面我们总结了怎么保护php中的cookie,get,post,files数据,有需要的朋友可参考一下.代码如下:

<?php 
$magic_quotes_gpc = get_magic_quotes_gpc(); 
@extract(daddslashes($_COOKIE)); 
@extract(daddslashes($_POST)); 
@extract(daddslashes($_GET)); 
if(!$magic_quotes_gpc) { 
    $_FILES = daddslashes($_FILES); 
}


daddslashes函数,代码如下:

//转译字符函数 
function daddslashes($string) { 
    if(!is_array($string)) return addslashes($string); 
    foreach($string as $key => $val) $string[$key] = daddslashes($val); 
    return $string; 
}


永久链接:http://www.phprm.com/develop/fs4661.html

转载随意!带上文章地址吧。

标签:magic_quotes_gpc $_server变量

相关文章

发表留言