<?php
define("IS_ENV_PRODUCTION",true);
error_reporting(E_ALL | E_STRICT);
ini_set("display_errors",!IS_ENV_PRODUCTION);
ini_set("error_log",'log/phperror.txt');
date_default_timezone_set('Asia/Harbin');
if (get_magic_quotes_gpc())
{
function _stripslashes_rcurs($variable, $top = true)
{
$clean_data=array();
foreach($variable as $key => $value)
{
$key = $top ? $key : stripslashes($key);
$clean_data[$key] = is_array($value) ? _stripslashes_rcurs($value, false) :
stripslashes($value);
}
return $clean_data;
}
$_GET = _stripslashes_rcurs($_GET);
$_POST = _stripslashes_rcurs($_POST);
}?>
define("IS_ENV_PRODUCTION",true);
error_reporting(E_ALL | E_STRICT);
ini_set("display_errors",!IS_ENV_PRODUCTION);
ini_set("error_log",'log/phperror.txt');
date_default_timezone_set('Asia/Harbin');
if (get_magic_quotes_gpc())
{
function _stripslashes_rcurs($variable, $top = true)
{
$clean_data=array();
foreach($variable as $key => $value)
{
$key = $top ? $key : stripslashes($key);
$clean_data[$key] = is_array($value) ? _stripslashes_rcurs($value, false) :
stripslashes($value);
}
return $clean_data;
}
$_GET = _stripslashes_rcurs($_GET);
$_POST = _stripslashes_rcurs($_POST);
}?>
{
function _stripslashes_rcurs($variable, $top = true)
{
$clean_data=array();
foreach($variable as $key => $value)
{
// 如果上面函数的第二个参$top数为 true ,那么就不需要去除转义斜杠了,否则就要用stripslashes()。
$key = $top ? $key : stripslashes($key);
// 判断$variable是否只是一维数组,如果不是,就对$variable[$key]继续 _stripslashes_rcurs()
$clean_data[$key] = is_array($value) ? _stripslashes_rcurs($value, false) : stripslashes($value);
}
return $clean_data;
}
$_GET = _stripslashes_rcurs($_GET);
$_POST = _stripslashes_rcurs($_POST);
}这段代码就是对经过自动转义的表单数据再去除转义符 可以看看 get_magic_quotes_gpc addlashes()