您现在的位置是:首页 > 二次开发 > ecshop网站首页ecshop

Ecshop在PHP5.6版本报错的解决方法

简介

问题1:

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in cls_template.php XXX line


出错原因:

出现以上问题是 preg_replace() 函数中用到的修饰符 /e 在 PHP5.5.x 中已经被弃用了。在PHP 5.5以上的版本用 preg_replace_callback 函数替换了 preg_replace函数。


解决方法:

解决问题的方法就是将代码中使用 preg_replace 函数的部分全部替换成 preg_replace_callback 函数,并且将一被废弃的 /e 修饰符 删除。


例子:

return preg_replace("/{([^\}\{\n]*)}/e", "\$this->sel ect('\\1');", $source);

替换为

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


第550行

原有内容:

//$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val);

修改后内容:

$val = preg_replace_callback('/\[([^\[\]]*)\]/is',function ($matches) {return'.'.str_replace('$','\$',$matches[1]);},$val);

第491行

原有内容:

//$out = "<?php" . '$k = ' . preg_replace("/(\'\\$[^,] )/e" , "stripslashes(trim('\\1','\''));",var_export($t, true)) . ";";

修改后内容:

$out = "<?php" . '$k = ' . preg_replace_callback("/(\'\\$[^,] )/" ,function($match){return stripslashes(trim($match[1],'\''));}, var_export($t, true)) . ";


问题2:

Strict Standards: Only variables should be passed by reference in ......\includes\cls_template.php on line 418


出错原因:

出现这个问题的原因,貌似在php5.4中array_shift只能为变量,不能是函数返回值。


解决方法:

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

替换成

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


问题3:

F:\nswlptsxl\ecshop\ec\includes\modules\payment\alipay.php on line 88


解决方法:

删除76行左右的

/**
 * 构造函数
 *
 * @access  public
 * @param
 *
 * @return void
 */
function alipay()
{
}

以及90行的

$this->alipay();



问题4:

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in F:\nswlptsxl\ecshop\ec\includes\cls_template.php on line 489


解决方法:

把489行的:

$out = "<?php \n" . '$k = ' . preg_replace("/(\'\\$[^,]+)/e" , "stripslashes(trim('\\1','\''));", var_export($t, true)) . ";\n";


修改成:

$out =  "<?php \n" . '$k = ' . preg_replace_callback("/(\'\\$[^,]+)/", function($r) { return stripslashes(trim($r[1],'\'')); }, var_export($t, true)). ";\n";


文章评论

Top