Function eregi is deprecated (解决方法)
更新时间:2013年06月21日 10:16:25 作者:
本篇文章是对Function eregi() is deprecated错误的解决方法进行了详细的分析介绍,需要的朋友参考下
在php升级到php5.3之后后,在使用的过程经常发现有的程序会出现Function eregi() is deprecated 的报错信息。是什么原因呢?
这是因为php5.3中不再支持eregi()函数,而使用preg_match()函数替代。
解决的方法是:将eregi()函数替换成preg_match() 函数。
if(eregi('^test',$file))
可以替换为
if(preg_match('/^test/i',$file))
————-
PHP 5.3.0 之後的 regex, 希望使用 PCRE 的規格, POSIX Regex 都不建議使用了(統一 Regex, 避免規格太多?).
所以下述是不建議使用的 Function (POSIX), 與建議替換成的 Function (PCRE) 列表, 詳可見: PHP:
Differences from POSIX regex
* POSIX → PCRE
* ereg_replace() → preg_replace()
* ereg() → preg_match()
* eregi_replace() → preg_replace()
* eregi() → preg_match()
* split() → preg_split()
* spliti() → preg_split()
* sql_regcase() → No equivalent
* 需要 regex 的 split, 可用 preg_split() 代替
* 不需要 regex, 只要要快速分割固定的字串, 可用 explode() 代替. (速度會比需要 regex 的快很多)
这是因为php5.3中不再支持eregi()函数,而使用preg_match()函数替代。
解决的方法是:将eregi()函数替换成preg_match() 函数。
if(eregi('^test',$file))
可以替换为
if(preg_match('/^test/i',$file))
————-
PHP 5.3.0 之後的 regex, 希望使用 PCRE 的規格, POSIX Regex 都不建議使用了(統一 Regex, 避免規格太多?).
所以下述是不建議使用的 Function (POSIX), 與建議替換成的 Function (PCRE) 列表, 詳可見: PHP:
Differences from POSIX regex
* POSIX → PCRE
* ereg_replace() → preg_replace()
* ereg() → preg_match()
* eregi_replace() → preg_replace()
* eregi() → preg_match()
* split() → preg_split()
* spliti() → preg_split()
* sql_regcase() → No equivalent
* 需要 regex 的 split, 可用 preg_split() 代替
* 不需要 regex, 只要要快速分割固定的字串, 可用 explode() 代替. (速度會比需要 regex 的快很多)
相关文章
shopex主机报错误请求解决方案(No such file or directory)
最近vps客户和服务托管客户安装了shopex网店系统,他们的主机都报错,错误特点一样,针对这个错误我司技术推出shopex主机报错误请求解决方案,希望能给予各位一点帮助2011-12-12通过JavaScript或PHP检测Android设备的代码
在此列出一些能够在iOS的最大竞争者——安卓(Android)系统的检测方法。即通过JavaScript或PHP检测Android设备,给大家提供参考。2011-03-03
最新评论