Implementation code:
Copy code The code is as follows:
function addslashes_deep($value)
{
//The most classic recursion in history, done in one line
return is_array($value) ? array_map('addslashes_deep', $value) : addslashes($value);
}
//Test data
$_POST['STR'] = "'fanglor ' is a boy >'";
$_GET['STR1'] = 'fanglor " is a boy >' ;
echo 'The current get_magic_quotes_gpc is '.get_magic_quotes_gpc();
echo "
";
//Determine whether get_magic_quotes_gpc is currently enabled
if (!get_magic_quotes_gpc()){
$_POST = addslashes_deep($_POST);
$_GET = addslashes_deep($_GET);
$_COOKIE = addslashes_deep($_COOKIE);
}
//Print results
var_dump ($_POST);
echo "
";
var_dump ($_GET);
?>
Print result:
The current get_magic_quotes_gpc is 0
array(1) { ["STR"]=> string(30) "'fanglor ' is \ a boy >'" }
array(1) { ["STR1"]=> string(26) "fanglor " is \ a boy >" }
http://www.bkjia.com/PHPjc/328076.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/328076.htmlTechArticleImplementation code: Copy the code as follows: ?php function addslashes_deep($value) { //The most classic recursion in history , return is_array($value) ? array_map('addslashes_deep',...