PHP6, Magic quotes & the “best practice“

7/24/2007 12:30:00 AM | Permanent Link | Comments (11)
All the code that was employing the considered “best practice“ for Magic Quotes in PHP, apparently fails when it comes to PHP6, since magic quotes has been officially removed from the sources; a good thing, of course. I discovered this as we moved to a new version of PHP @ work.

So an updated version of what I think would be “best practice“, and backwards compatible.

<?php
function stripslashes_deep($value)
{
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);
return $value;
}

if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
$_GET = stripslashes_deep($_GET);
$_POST = stripslashes_deep($_POST);
$_COOKIE = stripslashes_deep($_COOKIE);
$_REQUEST = stripslashes_deep($_REQUEST);
}

[ 11 Comments ]

Mukul Sabharwal is an engineering student at Iowa State University and writes software for a living.

Comments (Add Comment)

11 comment(s)

why not have only stripslashes? why need deep?

nice tip

The deep is used for arrays and recursive calls to strip them too. So for like multi-select boxes

Hopefully they'll wisen up and restore the same function that just returns false.

http://www.xbox360achievements.org/forum/member.php?u=262782 zyprexa positive helped zyprexa 5 mg comparsion drugs zyprexa class action http://www.xbox360achievements.org/forum/member.php?u=262789 zyprexa skin side effects reducing zyprexa dose what is zyprexa http://www.xbox360achievements.org/forum/member.php?u=262779 zyprexa attorneys los angeles jack b weinstein zyprexa lawsuit claims zyprexa for pain http://www.xbox360achievements.org/forum/member.php?u=262789 zyprexa suits june 2007 alzheimer's zyprexa drug zyprexa http://www.xbox360achievements.org/forum/member.php?u=262782 zyprexa class action dosage of zyprexa for bipolar zyprexa acne http://www.xbox360achievements.org/forum/member.php?u=262777 zyprexa mdl generic zyprexa zyprexa overdose http://www.xbox360achievements.org/forum/member.php?u=262787 zyprexa 5 mg zyprexa and tourettes syndrome zyprexa children http://www.xbox360achievements.org/forum/member.php?u=262783 zyprexa litigants class action lawsuit zyprexa insomnia zyprexa diabetes http://www.xbox360achievements.org/forum/member.php?u=262783 zyprexa settlement zyprexa for anxiety zyprexa and marijuana http://www.xbox360achievements.org/forum/member.php?u=262795 new generic zyprexa zyprexa zydis zyprexa recall southern california

miley cyrus nude [url=http://www.ipetitions.com/petition/mileycyrus]miley cyrus nude[/url] paris hilton nude [url=http://www.ipetitions.com/petition/parishilt]paris hilton nude[/url] kim kardashian nude [url=http://www.ipetitions.com/petition/kimkardashian45]kim kardashian nude[/url] kim kardashian nude [url=http://www.ipetitions.com/petition/celebst]kim kardashian nude[/url]

http://www.xbox360achievements.org/forum/member.php?u=273719 lilly zyprexa zyprexa attorneys california zyprexa and tourettes syndrome http://www.xbox360achievements.org/forum/member.php?u=273705 zyprexa package insert zyprexa vertigo zyprexa litigants class action lawsuit http://www.xbox360achievements.org/forum/member.php?u=273716 alzheimer's zyprexa new generic zyprexa zyprexa side effect http://www.xbox360achievements.org/forum/member.php?u=273710 zyprexa zydis weight gain zyprexa diet information new generic zyprexa http://www.xbox360achievements.org/forum/member.php?u=273705 dosages of zyprexa zyprexa causing alcohol intolerence zyprexa long term http://www.xbox360achievements.org/forum/member.php?u=273702 zyprexa patient info zyprexa generic version zyprexa information alcohol http://www.xbox360achievements.org/forum/member.php?u=273719 zyprexa for panic disorder should you mix cymblata and zyprexa zyprexa diabetes claim http://www.xbox360achievements.org/forum/member.php?u=273717 zyprexa causes glocoma buy zyprexa without prescription zyprexa lawyers california http://www.xbox360achievements.org/forum/member.php?u=273719 zyprexa testosterone zyprexa patients assistance zyprexa tabs http://www.xbox360achievements.org/forum/member.php?u=273717 zyprexa jenner zyprexa and diabetes zyprexa psycotic reactions

Hello! Can you tell me how i can register mail at google [url=http://google.com]google[/url] http://google.com

Hello! Can you tell me how i can register mail at google [url=http://google.com]google[/url] http://google.com

jacksonville fl singles church [url=http://loveepicentre.com/]adult dating services[/url] speed dating coventry http://loveepicentre.com/ gay dating

Archives

RSS for mjsabby.com CSS2 Valid XHTML 1.0 Strict Valid

A trip down memory lane; help yourself, and go browsing my older posts ...

Elsewhere

Advertisement