ecshop常见报错原因,分析

ECSHOP完美解决Deprecated: preg_replace()报错的问题

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

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

替换为

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

问题解决。

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

改为$val = preg_replace_callback("/\[([^\[\]]*)\]/", function($r) {return '.'.str_replace('$','$',$r[1]);}, $val);

3问题:Strict Standards:Redefining already defined constructor for class alipay in /.../includes/modules/payment/alipay.php on line 85

原因:

这个问题是PHP高低版本中,对于类的构造函数写法不一样造成的。

在PHP4中,类的构造函数是一个和类名同名的函数作为构造函数的,

而在PHP5以后,用__construct()作为构造函数,但同时也支持PHP4中用类同名的构造函数方法,

同时使用的时候,请注意 同名函数不能放在__construct()构造函数前面。

修改:

class test

{

    function __construct()  //此构造函数须写在前
    {
       //php代码
    }

    function test()  //此函数须写在后

    {

    //php代码

    }

}

3、Strict Standards: Non-static method cls_image::gd_version() should not be called statically in //includes/lib_base.php on line 346

 解决:找到install/includes/lib_installer.php中的第31行   return cls_image::gd_version();然后在找到include/cls_image.php中的678行,发现gd_version()方法未声明静态static,所以会出错。这时候只要:

  1)将function gd_version()改成static function gd_version()即可。

  2)或者将install/includes/lib_installer.php中的第31行return cls_image::gd_version();改成:

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

4、Strict Standards: mktime(): You should be using the time() function instead in //admin/sms_url.php on line 31

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

按照路径 D:\wamp\wamp\www\ECShop\upload\admin\sms_url.php 找到文件第31行:

$auth = mktime();

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

$auth = time();

猜你喜欢

转载自blog.csdn.net/qq_39516866/article/details/81458659
今日推荐