PHP7 Call to undefined function eregi()

Apache 里的错误报告如下:

PHP Fatal error:  Uncaught Error: Call to undefined function eregi() in …

导致Magento 的 Payway 插件无法正常使用!

PHP5.3 的话则会提示:Function eregi() is deprecated…


搜了一下这个函数,发现官方介绍里这么说明:

(PHP 4, PHP 5)

eregiCase insensitive regular expression match

This function was DEPRECATED in PHP 5.3.0, and REMOVED in PHP 7.0.0.

Alternatives to this function include:


就是说在 PHP5.3、PHP7 里是不能正常使用该函数的。

解决办法是用 preg_match() i 参数替代,可以把相关代码做如下修改:

eregi ( “^[_0-9a-z-]{1,30}$”, $key );

改为:

preg_match ( “/^[_0-9a-z-]{1,30}$/i”, $key );

 

参考:http://php.net/manual/en/function.eregi.php

 

相关文章