php字符前加上反斜杠,包括 单引号、双引号、反斜杠

  1. function d_addslashes($string, $force = 0) {
  2. if(!$globals['magic_quotes_gpc'] || $force) {
  3. if(is_array($string)) {
  4. foreach($string as $key => $val) $string[$key] = d_addslashes($val, $force);//开源代码phpfensi.com
  5. }
  6. else $string = addslashes($string);
  7. }
  8. return $string;
  9. }