ECShop报错问题

ECShop部署在PHP5.5以上版本时会出现错误,原因是PHP5.5对部分函数preg_replace进行了修改,有些参数不再支持,因此要对代码进行修改,修改后在后台清除缓存,然后刷新页面。


1、Strict Standards: Only variables should be passed by reference in ... on line 418
原因:PHP5.3以上默认只能传递具体的变量,而不能通过函数返回值传递,所以这段代码中的explode就得移出来重新赋值了:
解决方法:includes\cls_template.php,407行左右:
          $tag_sel = array_shift(explode(' ', $tag));
          改为: 
     $tagArr = explode(' ', $tag);
          $tag_sel = array_shift($tagArr); 




2、Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in ... on line 288
原因:PHP5.5对preg_replace进行了修改,/e参数不再支持,需要改用preg_replace_callback来调用,此错误会在多处发生。
解决方法: 
    1)includes\cls_template.php,mobile\includes\cls_template.php 288行左右:
       return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source);
       改为:
       return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return $this->select($r[1]); }, $source);


    2)includes\cls_template.php 484行左右:
       $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";


    3)includes\cls_template.php,mobile\includes\cls_template.php 1055行左右:
       $pattern     = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/se';
       $replacement = "'{include file='.strtolower('\\1'). '}'";
       $source      = preg_replace($pattern, $replacement, $source);
       改为:
       $source = preg_replace_callback("/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/s", function($r) { return '{include file='. strtolower($r[1]) . '}'; }, $source);


3、PHP仅显示严格错误的设置方法:
   1)php.ini里面修改error_reporting,改成error_reporting=E_ALL & ~E_STRICT,这个意思是显示所有除了严格模式的错误。
   2)修改改完了之后需要到 includes\init.php中,将第45行的:
      @ini_set('display_errors',1);
      改为:
      @ini_set('display_errors',0);
   这样程序可以正确运行,不过错误并没有排除,而且也不适合开发调试。

猜你喜欢

转载自blog.csdn.net/yanjinrong/article/details/55214206
今日推荐