ecshop适合一些刚开始的商城,但是由于官方的新版本3.0,还很少有人用,所以市面上多是2.7.3的版本。

只是2.7.3版本的对php版本兼容有要求,php5.3版本以上的各种显示错误。

所以就需要修改了,具体修改的代码网上也有很多了,我就不都说了。

只是简单说下几个常见的以及一个有2种修改方法的。

1:
错误提示:Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in
对应代码:return preg_replace(“/{([^\}\{\n]*)}/e”, “\$this->select(‘\\1’);”, $source);

修改为

return preg_replace_callback("/{([^\}\{\n]*)}/", function($r){return $this->select($r[1]);}, $source);

2:
错误提示:Strict Standards: Only variables should be passed by reference in
对应代码:$tag_sel = array_shift(explode(‘ ‘, $tag));
修改为

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

3:这个是很多人容易修改错误的
错误提示:Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback
instead in
对应代码:

$out = "
这一句有2种修改方法
其一:

$out = "
但是这样会导致某些模版的调用没用,就是不显示某些数字了吧。
然后就可以修改为其二:

$replacement = preg_replace_callback("/(\'\\$[^,]+)/" ,
function($matcher){
return stripslashes(trim($matcher[1],'\''));
},
var_export($t, true));
$out = "

4:
错误提示:Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in
对应代码:

$pattern = '/.*?/se';
$replacement = "'{include file='.strtolower('\\1'). '}'";
$source = preg_replace($pattern, $replacement, $source);

修改为:

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

5:
错误提示:Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in
对应代码:
$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val);
修改为
$val =preg_replace_callback("/\[([^\[\]]*)\]/is", function(){return '.'.str_replace('$','\$','\\1');}, $val);

6:
错误提示:Strict Standards: Only variables should be passed by reference in
对应代码:
$ext = end(explode('.', $tmp));

修改为:

$ext = explode('.', $tmp);
$ext = end($ext);

7:
错误提示:Strict Standards: Non-static method cls_image::gd_version() should not be called statically in
对应代码:
return cls_image::gd_version();
修改为:

$p = new cls_image();
return $p->gd_version();

8:
错误提示:Strict Standards: Redefining already defined constructor for class alipay in
支付宝支付问题,给他们换个位置就行,其他文件也一样的。
class alipay
{
function __construct()
{
$this->alipay();
}
function alipay()
{
}

9:
时间问题Strict Standards: mktime(): You should be using the time() function instead in

$auth = mktime();

修改为:

$auth = time();