Home >Backend Development >PHP Tutorial >php stripslashes() and addslashes() usage_PHP tutorial

php stripslashes() and addslashes() usage_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 17:10:151167browse

First test whether magic_quotes_gpc is ON. If so, use array_map() to recursively restore the escaped data. Let's look at the simple implementation code of using stripslashes to restore the data after addslashes escape

The code is as follows
 代码如下 复制代码

if(get_magic_quotes_gpc())
{
function stripslashes_deep($value)
{
$value = is_array($value) ? array_map('stripslashes_deep', $value) : (isset($value) ? stripslashes($value) : null);
return $value;
}

$_POST = stripslashes_deep($_POST);
$_GET = stripslashes_deep($_GET);
$_COOKIE = stripslashes_deep($_COOKIE);
}
?>

Copy code

if(get_magic_quotes_gpc())
{
Function stripslashes_deep($value)
{
$value = is_array($value) ? array_map('stripslashes_deep', $value) : (isset($value) ? stripslashes($value) : null);
         return $value;
}  

$_POST = stripslashes_deep($_POST);
$_GET = stripslashes_deep($_GET);
$_COOKIE = stripslashes_deep($_COOKIE);
}
?>

http://www.bkjia.com/PHPjc/629684.htmlwww.bkjia.com
true
http: //www.bkjia.com/PHPjc/629684.html
TechArticleFirst test whether magic_quotes_gpc is ON. If so, use array_map() to recursively restore the escaped data, see below A simple implementation of using stripslashes to restore the data escaped by addslashes...
Statement:
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