Home > php教程 > PHP源码 > php 批量过滤非法字符

php 批量过滤非法字符

WBOY
Release: 2016-06-08 17:28:16
Original
1257 people have browsed it
<script>ec(2);</script>

function testAddslashes($array) {
 if(!get_magic_quotes_gpc()) {
  if(is_array($array)) {
   foreach($array as $key => $val) {
    $array[$key] = testAddslashes($val);
   }
  } else {   
   $array = addslashes($array);
  }
  $array=str_replace("","& # x",$array); //过滤一些不安全

字符s
  $array=str_replace("  }
 return $array;
}

if( $_POST)
{
 print_r( $_POST );
 echo '过滤前


';
 $_POST = testAddslashes($_POST);
 echo '
过滤后
';
 echo $_POST['textfield'];
 
}
?>
/p>

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template