Home > php教程 > php手册 > PHP5下$_SERVER变量不再受magic_quotes_gpc保护

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

WBOY
Release: 2016-06-13 10:12:22
Original
1159 people have browsed it

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

 代码如下 复制代码
$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;
 }

?>

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template