note 68150 deleted from function.stripslashes by philip
| From: | philip@php.net | Date: | Wed, 07 Feb 2007 04:54:48 +0000 |
| Subject: | note 68150 deleted from function.stripslashes by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-123006@lists.php.net to get a copy of this message | ||
Note Submitter: kevin at digital-nw dot com
----
Why double nest the if's like that? All you need to do is check that the value is a string type
as only these are effected by GPC. Also need to check for empty to avoid the NULL issues, and if it
is empty "" there isn't much reason to do anything anyway.
<?
if ( get_magic_quotes_gpc() ) {
function stripslashes_deep($value) {
if( is_array($value) )
{
$value = array_map('stripslashes_deep', $value)
}
elseif ( !empty($value) && is_string($value) )
{
$value = stripslashes($value);
}
return $value;
}
$_POST = stripslashes_deep($_POST);
$_GET = stripslashes_deep($_GET);
$_COOKIE = stripslashes_deep($_COOKIE);
}
?>