Home > Backend Development > PHP Tutorial > The $_SERVER variable is no longer protected by magic_quotes_gpc under PHP5_PHP Tutorial

The $_SERVER variable is no longer protected by magic_quotes_gpc under PHP5_PHP Tutorial

WBOY
Release: 2016-07-13 17:10:41
Original
781 people have browsed it

In the php5 environment, our $_SERVER variable will no longer be protected by magic_quotes_gpc. As for how the program can strengthen its own security, below we summarize how to protect cookie, get, post, files data in php. Friends in need can refer to it.

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

The code is as follows //Translation character function function daddslashes($string) { If(!is_array($string)) return addslashes($string); foreach($string as $key => $val) $string[$key] = daddslashes($val);

Return $string;

} ?>
http://www.bkjia.com/PHPjc/629649.htmlwww.bkjia.com
truehttp: //www.bkjia.com/PHPjc/629649.htmlTechArticleIn the php5 environment, our $_SERVER variable will no longer be protected by magic_quotes_gpc. As for how the program can strengthen itself Security, below we summarize how to protect cookies, get,...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
代码如下 复制代码

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

Copy code