您的位置:首页 > 其它

参数过滤

2015-07-15 16:26 337 查看
/**
* 参数过滤
*    @param string/array $str
*    @return string/array
*/
function get_field($str){
  if(empty($str)){return;}
  $string = preg_replace('/select | insert | update | and | in | on | left | joins | delete | \% | \= | \/\* | \* | \.\.\/ | \.\/ | union | from | where | group | into | load_file | outfile /','',$str);
  $new_str = htmlspecialchars($string, ENT_COMPAT);
  $return = strip_tags(str_replace(PHP_EOL.PHP_EOL, PHP_EOL,$new_str));
  return $return;
}

$str = 'select * from table where id = 1 or name " ';
echo red_field($str);
输出:*tableid1 or name "
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: