| 238 | | |
| 239 | | /* Below is my test of the addcslashes function to mimic the mysql_real_escape_string function |
| 240 | | * |
| 241 | | * $array = array('\x00', '\x1a', '\n', '\r', '\\', "'", '"'); |
| 242 | | * foreach($array as $item) |
| 243 | | * { |
| 244 | | * echo addcslashes($item, '\\\'"').'<br />'; |
| 245 | | * } |
| 246 | | */ |
| 247 | | $characters = array('/\x00/', '/\x1a/', '/\n/', '/\r/', '/\\\/', '/\'/', '/\"/'); |
| 248 | | return preg_replace($characters, '\\', $str); |
| | 238 | |
| | 239 | $characters = array('/\x00/', '/\x1a/', '/\n/', '/\r/', '/\\\/', '/\'/'); |
| | 240 | $replace = array('\\\x00', '\\x1a', '\\n', '\\r', '\\\\', "''"); |
| | 241 | return preg_replace($characters, $replace, $str); |