码迷,mamicode.com
首页 > 其他好文 > 详细

ecshop那些事

时间:2015-12-02 22:43:18      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:

是不是对最新版本的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 ,在php 5.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);

 

替换为后,上传到服务器.然后进入后台,清空缓存即可. 

ecshop那些事

标签:

原文地址:http://www.cnblogs.com/bqx619/p/5014390.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!