Home  >  Article  >  php教程  >  过滤转义字符

过滤转义字符

WBOY
WBOYOriginal
2016-06-08 17:30:111119browse
<script>ec(2);</script>

unction cg_stripslashes($array) {
 if (is_array($array)) {
  foreach ($array as $k => $v) {
   $array[$k] = cg_stripslashes($v);
  }
 } else if (is_string($array)) {
  $array = stripslashes($array);
 }
 return $array;
}

// 添加转义
function cg_addslashes($string) {
 if(is_array($string)) {
  foreach($string as $key => $val) {
   $string[$key] = cg_daddslashes($val);
  }
 } else {
  $string = addslashes($string);
 }
 return $string;
}
?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn