Home > Backend Development > PHP Tutorial > php5.3不支持eregi()函数,用preg_match如何转换?求大神指教

php5.3不支持eregi()函数,用preg_match如何转换?求大神指教

WBOY
Release: 2016-06-13 10:09:58
Original
1040 people have browsed it

php5.3不支持eregi()函数,用preg_match怎么转换?求大神指教!
function inject_check($sql_str) {
  $check=eregi('select|insert|update|delete|\'|\\*|\*|\.\.\/|\.\/|union|into|load_file|outfile',$sql_str); // 进行过滤
  if($check){
  echo "输入非法注入内容!";
  exit();
  }else{
  return $sql_str;
  }
}
今天上网找了段防止SQL注入的方法,但是运行后发现eregi()这个函数在5.3版本已经不能使用了,提示了使用过期的函数,所以我就上网找资料,网上评论也是说现在是用preg_match()函数代替eregi()函数,但是我把函数名改成preg_match又不行,似乎参数不对,麻烦知道的教下我,正确的preg_match应该怎么改,谢谢!

------解决方案--------------------

PHP code
preg_match('/select|insert|update|delete|\'|\\*|\*|\.\.\/|\.\/|union|into|load_file|outfile/i',$sql_str);<br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
PHP code
function inject_check($sql_str) {    $check=preg_match('/select|insert|update|delete|\'|\\*|\*|\.\.\/|\.\/|union|into|load_file|outfile/i',$sql_str); // 进行过滤    if($check){        echo "输入非法注入内容!";        exit();    }else{        return $sql_str;    }}<div class="clear">
                 
              
              
        
            </div>
Copy after login
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template