Ecshop解决Deprecated: preg_replace()报错
安装Ecshop后,运行出现各种问题,其中 Deprecated: preg_replace() 之类的报错最多,下面贴出解决方案:
错误原因:
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......
解决办法:
1. Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in \includes\cls_template.php on line 300
原有内容:
return preg_replace("/{([^\}\{]*)}/e", "\$this->select('\\1');", $source);
修改后内容:
return preg_replace_callback("/{([^\}\{]*)}/", function($r) { return $this->select($r[1]); }, $source);
2. Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in \includes\cls_template.php on line 491
原有内容:
$out = "
共有 0 条评论