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 的快很多)
如对本文有疑问,
点击进行留言回复!!
相关文章:
-
-
-
-
网安追踪流程
1.不用代理网民发帖流程:发帖人 → ISP → 服务器托管商 → 服务器网警追踪流程:网监 → 服务器IP →...
[阅读全文]
-
-
-
HTTP状态码大全
转自:https://www.cnblogs.com/lxinxuan/archive/2009/10/22/1...
[阅读全文]
-
-
-
-
网友评论