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 ,在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);

 

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

posted @ 2015-12-02 21:46  bqx619  阅读(120)  评论(0编辑  收藏  举报