Created
October 21, 2012 05:26
-
-
Save johnsardine/3925992 to your computer and use it in GitHub Desktop.
Real Escape String
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Escapes a string or array just like mysql_real_escape_string but does not require a db connection like mysql_* one does | |
function real_escape_string($input) { | |
if(is_array($input)) | |
return array_map(__METHOD__, $input); | |
if(!empty($input) && is_string($input)) { | |
return str_replace(array('\\', "\0", "\n", "\r", "'", '"', "\x1a"), array('\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'), $input); | |
} | |
return $input; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment