php5.3提示Function ereg() is deprecated Error问题解决方法
2014-11-12 15:58
801 查看
本文实例讲述了php5.3提示Function ereg() is deprecated Error问题解决方法。分享给大家供大家参考。具体实现方法如下:
一、问题:
PHP 5.3 ereg() 无法正常使用,提示“Function ereg() is deprecated Error”是因为它长ereg 函数进行了升级处理,需要像preg_match使用/ /来规则了,当然也是php5.3把ereg给废掉的节奏了。
PHP 5.3 ereg() 无法正常使用,提示“Function ereg() is deprecated Error”。
问题根源是php中有两种正则表示方法,一个是posix,一个是perl,php6打算废除posix的正则表示方法所以后来就加了个preg_match。此问题解决办法很简单,在ereg前加个过滤提示信息符号即可:把ereg()变成@ereg()。这样屏蔽了提示信息,但根本问题还是没有解决,php在5.2版本以前ereg都使用正常,在5.3以后,就要用preg_match来代替ereg。所以就需要变成这样。
原来:ereg("^[0-9]*$",$page)变成:preg_match("/^[0-9]*$/",$page)
特别提醒:posix与perl的很明显的表达区别就是是否加斜杠,所以与ereg相比,后者在正则的前后分别增加了两个"/"符号,不能缺少。
例如:
改前:
$sql_str = strtolower($sql_str);
return eregi('fopen|post|eval|select|insert|and|or|update|delete|'|/*|*|../|./|union|into|load_file|outfile', $sql_str); // 进行过滤
}
二、解决方法:
找到代码所在的文件位置:
复制代码 代码如下: function inject_check($sql_str) {
$sql_str = strtolower($sql_str);
return preg_match('/fopen|post|eval|select|insert|and|or|update|delete|'|/*|*|../|./|union|into|load_file|outfile/', $sql_str); // 进行过滤
}
注意:一定要加'/'开头与结束。此段参考://www.jb51.nethttps://www.geek-share.com/detail/2582744073.html
补充:此问题在php5.2之前版本不会出现。
希望本文所述对大家的PHP程序设计有所帮助。
您可能感兴趣的文章:
相关文章推荐
- php5.3提示Function ereg() is deprecated Error问题解决方法
- php5.3开始出现的Function ereg() is deprecated Error问题解决办法
- php5.3开始出现的Function ereg() is deprecated Error问题解决办法
- php5.3开始出现的Function ereg() is deprecated Error问题解决办法
- php5.3开始出现的Function ereg() is deprecated Error问题解决办法
- php5.3开始出现的Function ereg() is deprecated Error问题解决办法
- php5.3开始出现的Function ereg() is deprecated Error问题解决办法
- DedeCMS Error: (PHP 5.3 and above) Please set 'request_order' ini value to i报错解决方法
- IAR 提示 Error[Li005]: no definition for ...的错误 的问题的解决方法
- php使用ZipArchive提示Fatal error: Class ZipArchive not found in的解决方法
- php使用ZipArchive提示Fatal error: Class ZipArchive not found in的解决方法
- php5.3.*编译出现make: *** [ext/gd/libgd/gd_compat.lo] Error 1的解决方法
- pb9.0 编绎成DLL类型时,提示"Error opening file 'c:/windows/system32/cgen/ent32.h" 问题的解决方法
- mysql处理添加外键时提示error 150 问题的解决方法
- php5.3.*编译出现make: *** [ext/gd/libgd/gd_compat.lo] Error 1 解决方法
- PHP执行Curl时报错提示CURL ERROR: Recv failure: Connection reset by peer的解决方法
- php Function ereg() is deprecated的解决方法
- php5.3.*编译出现make: *** [ext/gd/libgd/gd_compat.lo] Error 1 解决方法
- PHP imagick-3.1.0RC2无法安装,提示fatal error: wand/MagickWand.h: No such file or directory 解决方法
- Apache2.2整合PHP5.3以上的版本时提示错误Cannot load php5apache2_2.dll into server解决方法