Skip to content

Instantly share code, notes, and snippets.

@andrewlkho
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewlkho/9943902 to your computer and use it in GitHub Desktop.
Save andrewlkho/9943902 to your computer and use it in GitHub Desktop.
Turn off magic_quotes_gpc by default in PHP

This was originally posted on 2007-03-03 to http://andrewho.co.uk/weblog/magic-quotes-gpc-and-array-map

Juxta over on the TextDrive forum pointed out a good use of PHP's array_map() function that I hadn't thought of which gets around the annoying fact that some hosts set magic_quotes_gpc to on. In short:

if (get_magic_quotes_gpc()) {
    $_GET = array_map('stripslashes', $_GET);
    $_POST = array_map('stripslashes', $_POST);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment