ecshop针对PHP5.6.26的修改

来源:互联网 发布:电动车 知乎 编辑:程序博客网 时间:2024/05/20 16:41

错误1:

Strict standards: Non-static method cls_image::gd_version() should not be called statically in C:\wamp64\www\install\includes\lib_installer.php on line 31

找到include/cls_image.php中的678行

function gd_version()改成static function gd_version()即可。

 

错误2:

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in C:\wamp64\www\includes\cls_template.php on line 1071

原因:

preg_replace() 函数中用到的修饰符 /e 在 PHP5.5.x 中已经被弃用了。
如果你的PHP版本恰好是PHP5.5.X,那你的ECSHOP肯定就会报类似下面这样的错误:
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in......

其实从刚才的错误提示信息中我们也能看出一二,它提示我们使用 preg_replace_callback 来代替 preg_replace。
解决方法:
使用记事本或其他PHP编辑软件(如:editplus)打开文件 includes/cls_template.php ,找到
return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source);
替换为
return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return $this->select($r[1]); }, $source);
问题解决。
注:如果你的ECSHOP中其他文件也报类似的 preg_replace错误,请参照上面方法解决之,解决思路和解决方法是一样的。

错误3:

Strict standards: Only variables should be passed by reference in C:\wamp64\www\includes\cls_template.php on line 422

原因:

我的PHP版本是5.6.25PHP5.3以上默认只能传递具体的变量,而不能通过函数返回值传递,所以这段代码中的explode就得移出来重新赋值了

解决方法:

$tag_sel = array_shift(explode(' ', $tag));

替换为

$tagArr = explode(' ', $tag);
$tag_sel = array_shift($tagArr);

错误4:

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in C:\wamp64\www\includes\cls_template.php on line 1072

解决方法:

找到includes/cls_template.php1072行左右,

$pattern     = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/se';

$replacement = "'{include file='.strtolower('\\1'). '}'";

$source      = preg_replace($pattern, $replacement, $source);

替换为

$pattern     = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/s';

$source      = preg_replace_callback($pattern, function($r) { return  '{include file='.strtolower($r[1]). '}'; }, $source);

错误5:

Strict Standards: Redefining already defined constructor for class alipay in /data/web/includes/modules/payment/alipay.PHP on line 85

解决方法:

找到alipay.php中的class alipay{……},

function __construct()

    {

        $this->alipay();

}

移到

function alipay()

    {

}

之前。