AI编程生活评测

Ecshop安装过程中(PHP5.5.12)出现的几个错误

编程笔记 / 2016-02-16 / 3 min
以下是 ECshop 安装在 PHP5.5.12 环境下出现的报错,记录一下。 1.检查安装环境配置的时候报错:
Strict Standards: Non-static method cls_image::gd_version() should not be called statically in D:\X\www\ecshop\install\includes\lib_installer.php on line 31
原因:找到 install/includes/lib_installer.php 中的第31行 return cls_image::gd_version();然后在找到 includes/cls_image.php 中的 678 行,发现 gd_version() 方法未声明静态 static 。 解决:在 includes/cls_image.php 中的 678function gd_version() 改成 static function gd_version() 。 2.检测环境的时候提示:是否支持 JPEG 是不支持的。 解决:将 install/includes/lib_installer.php 中第 98JPG 修改成 JPEG
$jpeg_enabled = ($gd_info['JPEG Support']        === true) ? $_LANG['support'] : $_LANG['not_support'];
3.1安装完登录后台报错:
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in E:\phpDemo\ecshop\includes\cls_template.php on line 300
原因:在 PHP5.5 以上版本中 preg_replace() 函数中用到的修饰符 /ePHP5.5.x 中已经被弃用了。 解决:打开文件 includes/cls_template.php300
return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source);
//修改为:
return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return $this->select($r[1]); }, $source);
类似 preg_replace() 函数中用到的修饰符 /e 提示替换 preg_replace_callback()的还有几处: 3.2文件 includes/cls_template.php493 行:
$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.3文件 includes/cls_template.php553 行:
$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val);
//修改为:
$val = preg_replace_callback("/\[([^\[\]]*)\]/", function($r) {return '.'.str_replace('$','$',$r[1]);}, $val);
3.4文件 includes/cls_template.php1069 行:
$pattern = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/se';
$replacement = "'{include file='.strtolower('\\1'). '}'";
$source = preg_replace($pattern, $replacement, $source);

// 修改为:
$pattern = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/s';
$source = preg_replace_callback($pattern, function($r){return '{include file='.strtolower($r[1]). '}';}, $source);
4:错误信息:
Strict Standards: Only variables should be passed by reference in E:\web\shopex\includes\cls_template.php on line 422
原因: PHP5.3 以上默认只能传递具体的变量,而不能通过函数返回值传递,所以这段代码中的 explode 就得移出来重新赋值。 解决:将 includes\cls_template.php 文件 422
$tag_sel = array_shift(explode(' ', $tag));

// 修改为:
$tag_arr = explode(' ', $tag);
$tag_sel = array_shift($tag_arr);
5.后台错误信息:
Strict standards: mktime(): You should be using the time() function instead in E:\phpDemo\ecshop\admin\sms_url.php on line 31
打开 admin\sms_url.php 文件第 31 行: 打开 admin\shop_config.php332 行:
$auth = mktime();

// 修改为:
$auth = time();
  1. 马铃薯 2016-08-11 · 08:35

    includes/cls_template.php on line 553
    出现这种状况!

    1. 马铃薯 2016-08-11 · 08:35

      怎么改

      1. 行星带 2016-08-11 · 09:58

        看文章中3.3就是说这个的

  2. 灰常记忆 2016-03-04 · 13:20

    很详细,你在做ECSHOP?

    1. 行星带 2016-03-04 · 14:12

      没有,公司项目上用,我只负责打杂。