Page 1 of 1

Stripslashes if magic quotes enabled

Posted: Tue Oct 27, 2009 10:52 pm
by alex.barylski
I recall having a snippet of code in my application that checked for magic quotes and stripped quotes if nessecary using a recurvsive method. I searched google breifly and php.net and found this snippet:

Code: Select all

function stripslashes_deep($value)
{
    $value = is_array($value) ?
                array_map('stripslashes_deep', $value) :
                stripslashes($value);
 
    return $value;
}
I wrap this in a simple if() to test whether magic quotes are on or not and voila!!!

Can anyone see any enhancements or issues with this approach...

Cheers,
Alex

Re: Stripslashes if magic quotes enabled

Posted: Wed Oct 28, 2009 2:24 am
by requinix
Seems fine to me. Remember to execute this only if magic_quotes is enabled.