Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Gábor Papp
Added: Jan 30, 2021 8:21 AM
Views: 11
Tags: no tags
  1. function escape_string($param) {
  2.     if(is_array($param))
  3.         return array_map(__METHOD__, $param);
  4.  
  5.     if(!empty($param) && is_string($param)) {
  6.         return str_replace(array('\\', "\0", "\n", "\r", "'", '"', "\x1a"), array('\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'), $param);
  7.     }
  8.  
  9.     return $param;
  10. }
  11. $name = @trim(escape_string(stripslashes($_POST['name'])));
  12. foreach ($_GET as $key => $value) { $$key = @trim(escape_string(stripslashes($value)));  }
  13. foreach ($_POST as $key => $value) { $$key = @trim(escape_string(stripslashes($value)));  }