今天安装Ecshop后,运行出现各种问题,其中 Deprecated: preg_replace() 之类的报错最多,下面贴出解决方案:

错误原因:

  preg_replace() 函数中用到的修饰符 /e 在 PHP5.5.x 中已经被弃用了。

  如果你的PHP版本恰好是PHP5.5.X,那你的ECSHOP肯定就会报类似下面这样的错误:

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

解决办法:

  1. Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in \includes\cls_template.php on line 300   

    原有内容:

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

    修改后内容:

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

  2. Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in \includes\cls_template.php on line 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)) . ";"

  3. Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in \includes\cls_template.php on line 550

    原有内容:

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

    修改后内容:

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

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

    原有内容:

      $source = preg_replace($pattern, $replacement, $source);

    修改后内容:

      $source = preg_replace_callback($pattern, function ($matches) { return '{include file='.strtolower($matches[1]). '}';},$source);

  5. Strict Standards: Only variables should be passed by reference in ...\upload\includes\lib_main.php on line 1329

    原有内容:

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

    修改后内容:

      $extsub = explode('.', $tmp);

      $tmp = end($extsub);

      $tmp = basename($tmp,".$ext");

最后,将错误修改后,上传到服务器.然后进入后台,清空缓存,刷新页面即可。

最新文章

  1. C#编程:SqlCommand.Parameters.Add()方法的参数问题。
  2. live555编译、移植
  3. linux命令行与shell脚本编程大全---更多bash shell命令
  4. myeclipse2013 安装 egit
  5. acvitity的日常 启动模式(上)
  6. 卸载sql server 2012
  7. poj1274 匈牙利算法 二分图最大匹配
  8. Android显示表情对话框
  9. What is SignalR and Why Should I Use It?
  10. 文件保护DEP
  11. mongodb之java CRUD 简单操作
  12. int 与 int *
  13. win7 80端口被iis占用
  14. linux下安装apache环境
  15. 今天中了一个脚本病毒。把我的所有 html 加了 vbs 脚本,WriteData 是什么鬼?
  16. CentOS6系统防火墙开启、关闭、查看状态(转载)
  17. Mac 环境通用
  18. keepalived openssl 报错
  19. 定义的函数在main中调用时提示找不到标识符
  20. shell一次性执行多条命令

热门文章

  1. 3.JasperReports学习笔记3-在浏览器生成PDF文件
  2. LAMP 1.6 Discuz打开错误
  3. Java探索之旅(16)——异常处理
  4. Static与Const的区别
  5. std::min error C2059: 语法错误:“::” 的解决方法
  6. 阿里云OSS安装使用问题
  7. Umbraco中的RelatedLink的使用
  8. Note: Eleos: ExitLess OS Services for SGX Enclaves
  9. Codeforces Round #524 (Div. 2) D(思维,构造)
  10. java进阶——反射(Reflect)