PHP5.6 下 ECSHOP 错误信息

##问题1
`
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in D:\wyh\ecshop\includes\cls_template.php on line 300
`

1、错误原因:

preg_replace() 函数中用到的修饰符 /e 在 PHP5.5.x 中已经被弃用了。
如果你的PHP版本恰好是PHP5.5.X,那你的ECSHOP肯定就会报类似这样的错误。

2、解决办法:

一、将 cls_template.php的300行

`
return preg_replace("/{(1*)}/e", "$this->select('\1');", $source);
`
换成:
`
return preg_replace_callback("/{(2*)}/", function($r) { return $this->select($r[1]); }, $source);
`

二、将cls_template.php的493行

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

三、将cls_template.php的552行
$val = preg_replace("/([\[([\[]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val);

换成:

$val = preg_replace_callback("/([\[([\[]*)\]/", function($r) {return '.'.str_replace('$','$',$r[1]);}, $val);
四、将cls_template.php的1069行
$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);

问题2:

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

1、出错原因:

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

2、解决方法:

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

替换成

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

问题3:

   Strict Standards: mktime(): You should be using the time() function instead in ......\admin\shop_config.php on line 32

1、出错原因:

这个错误提示的意思:mktime()方法不带参数被调用时,会被抛出一个报错提示。

2、解决方法:

   $auth = mktime();

mktime()替换成time()方法,代码为:

$auth = time();

问题4:

Strict Standards: Non-static method cls_image::gd_version() should not be called statically in ......\includes\lib_base.php on line 346
或者
Strict Standards: Non-static method cls_image::gd_version() should not be called statically in ......\includes\lib_installer.php on line 31

如问题中提示的一样,因为 cls_image.phpgd_version() 不是 static 函数所以在lib_base.phplib_installer.php 中调用时才会出现以上问题。

解决方法:

 #####1、 解决方法:
首先在 lib_image.php 文件中,用 Shift+F 去搜索 gd_version 函数。然后在gd_version 方法前加 static 修饰符,是此函数变成静态函数。

#####2、解决方法2: 在lib_base.phplib_installer.php 函数中找到 cls_image::gd_version() 部分, 然后分别创建cls_image 实例,之后用创建的实例再去调用 gd_version() 函数。

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

  1. }{\n
  2. }{\n
  3. ,

非特殊说明,本博所有文章均为博主原创。

备注:相关侵权、举报、投诉及建议等,请联系站长

添加新评论

昵称
邮箱
网站