您现在的位置是:首页 > cms教程 > ecshop商城教程ecshop商城教程

ecshop2.7在php5.4以上版本报错的解决方法

浪虞2025-02-12 17:59:57ecshop商城教程已有17人查阅

导读是不是对较新版本的php适配ecshop很苦恼.最近我就遇到了这个事情,最终我花了一个小时的时间把这个问题解决了,特放出来,方便大家查阅。

是不是对较新版本的php适配ecshop很苦恼.最近我就遇到了这个事情,最终我花了一个小时的时间把这个问题解决了,特放出来,方便大家查阅。
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in \includes\cls_template.php on line 300 的错误,请问我应该怎么改?
这个错误存在于ecshop 较高版本2.7.3 ,在php5.4以上版本都存在.
下面我列出需要改动的地方.
用editplus或者其他工具,不建议用记事本,因为可能会改变原有文件的编码格式.
第300行
原有内容:
//return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source);
修改后内容:
return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return $this->select($r[1]); }, $source);
第491行
原有内容:
//$out = "<?php \n" . '$k = ' . preg_replace("/(\'\\$[^,]+)/e" , "stripslashes(trim('\\1','\''));", var_export($t, true)) . ";\n";
修改后内容:
$out = "<?php \n" . '$k = ' . preg_replace_callback("/(\'\\$[^,]+)/" ,
function($match){return stripslashes(trim($match[1],'\''));}
, var_export($t, true)) . ";\n";
第550行
原有内容:
//$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val);
修改后内容:
$val = preg_replace_callback(
'/\[([^\[\]]*)\]/is',
function ($matches) {
return '.'.str_replace('$','\$',$matches[1]);
},
$val
);
第1080行
原有内容:
//$source = preg_replace($pattern, $replacement, $source);
修改后内容:
$source = preg_replace_callback($pattern,
function ($matches) { return '{include file='.strtolower($matches[1]). '}';},
$source);
替换为后,上传到服务器.然后进入后台,清空缓存即可。

本文标签:

很赞哦! (0)

暂无内容
暂无内容
暂无内容
暂无内容
留言与评论 (共有 0 条评论)
昵称:
匿名发表 登录账号
         
验证码: