• ecshop在PHP 5.4以上版本各种错误问题处理


    ecshop在PHP 5.4以上版本各种错误问题处理

    www.111cn.net 更新:2014-06-21 编辑:kupeer 来源:转载
    在php5.4版本之后有很多的函数与功能进行丢弃与升级功能了,现在国内很多CMS都还未按php5.4标准来做了,下面我整理了一些在ecshop在PHP 5.4以上版本各种错误问题处理.

    1、PHP 5.4.X环境下安装ECShop出现“includes/cls_template.php on line 406”的解决方案。
    将 $tag_sel = array_shift(explode(‘ ‘, $tag)); 这句话拆开为两句。
    $tag_arr = explode(‘ ‘, $tag);
    $tag_sel = array_shift($tag_arr);
    array_shift() 的参数是引用传递的,5.3以上默认只能传递具体的变量,而不能通过函数返回值 end(&array) 也一样(后面也会有end的函数,也需要拆分为两行)。
    2、PHP 5.4.X环境下安装ECShop出现“includes/lib_base.php on line 346”的解决方案。
    将 cls_image.php 中 function gd_version() 改成 static function gd_version() 即可。
    3、后台点击 开店向导 警告的解决方案。
    admin/include/modules/payment 下的几个文件构造函数错误,删掉即可。
    4、php5.4下安装的时候处理问题,Strict Standards: Non-static method cls_image::gd_version() should not be called statically in \install\includes\lib_installer.php on line 31
    解决:找到install/includes/lib_installer.php中的第31行   return cls_image::gd_version();然后在找到include/cls_image.php中的678行,发现gd_version()方法未声明静态static,所以会出错。这时候只要:
    将function gd_version()改成static function gd_version()即可。
    5、安装好后出现 Strict standards: Only variables should be passed by reference in \includes\lib_main.php on line 1329
    $ext = end(explode('.', $tmp));
    修改为:
    $ext = explode('.',$tmp);
    $ext = end($ext);
    6、Strict standards: Only variables should be passed by reference in \includes\cls_template.php on line 418
    tag_sel = array_shift(explode(' ', $tag));
    修改为:
    $tag_arr = explode(' ', $tag); $tag_sel = array_shift($tag_arr);
    7、ECSHOP后台“商店设置”报错 Strict Standards: mktime(): You should be using the time() function instead in /www/web/zhuli/public_html/admin/sms_url.php on line 31。
    php版本问题  mktime()修改为  time()
    8、 ECSHOP后台“商店设置”报错 Strict Standards: mktime(): You should be using the time() function instead in /www/web/zhuli/public_html/admin/shop_config.php on line 32。
    php版本问题  mktime()修改为  time()


    3 安装好后出现 Strict standards: Only variables should be passed by reference in \includes\lib_main.php on line 1329
    $ext = end(explode('.', $tmp));
    修改为: 
    $ext = explode('.',$tmp);
     $ext = end($ext);
     Strict standards: Only variables should be passed by reference in \includes\cls_template.php on line 418
     tag_sel = array_shift(explode(' ', $tag)); 
    修改为:
     $tag_arr = explode(' ', $tag); $tag_sel = array_shift($tag_arr);
     
    array_shift() 的参数是引用传递的,5.3以上默认只能传递具体的变量,而不能通过函数返回值 end(&array) 也一样(后面也会有end的函数,也需要拆分为两行)。
     
    修改后到后台更新缓存
     
    4 后台 Strict standards: Redefining already defined constructor for class alipay in \includes\modules\payment\alipay.php on line 85
     后台更新缓存
     
    5 Strict standards: mktime(): You should be using the time() function instead in \admin\sms_url.php on line 31
    php版本问题  mktime()修改为  time()
     
    6 Strict standards: Redefining already defined constructor for class alipay in \includes\modules\payment\alipay.php on line 85Call Stack
    这里是php4与php5的区别
    PHP4中构造方法是一个与类同名的方法,而从PHP5开始,用__construct()做为构造方法,但仍然支持PHP4的构造方法。如果同时使用的话,如果 同名方法在前的话,则会报错

    只需要把 function __construct()移到同名函数之前

     7 Deprecated: Assigning the return value of new by reference is deprecated in  \admin\sitemap.php on line 46

     $sm     =& new google_sitemap();

         在5.3版本之后已经不允许在程序中使用”=&”符号。如果你的网站出现了Deprecated: Assigning the return value of new by reference is deprecated in 错误,别着急,先定位到出错的文件,查找下是不是在程序中使用了”=&”,例如阿兹猫刚才定位到网站程序中发现了下图的程序,发现使用了”=&”符号,去掉‘&’符号之后程序运行正常。
     
    8  PHPStrict Standards: Declaration of ucenter::login() should be compatible with integrate::login($username, $password, $remember = NULL) in \includes\modules\integrates\ucenter.php on line 52 PHP Strict Standards: Declaration of ucenter::add_user() should be compatible with integrate::add_user($username, $password, $email, $gender = -1, $bday = 0, $reg_date = 0, $md5password = '') in \includes\modules\integrates\ucenter.php on line 52 PHP Strict Standards: Declaration of ucenter::set_cookie() should be compatible with integrate::set_cookie($username = '', $remember = NULL) in \includes\modules\integrates\ucenter.php on line 52 
     
    PHP5.4,子类的方法名如果和父类方法名相同,则子类的参数列表也要和父类的参数列相同。
    修改接口文件里面的方法
     
    9  ecshop2.7.3 gbk版在php5.4下安装后,分类名称文字不显示问题
    htmlspecialchars()从 php5.4.0 版本开始第三个参数字符串编码的默认值改成了 UTF-8,而ecshop2.7.3 gbk版的中文编码是 GB2312 编码的,跟现在的默认参数不一致,导致所有htmlspecialchars()处理的字符都无法显示。
    解决办法:
    $str_converted = htmlspecialchars($str, ENT_COMPAT ,'GB2312');
    建议php5.4下不要安装gbk编码ecshop。

    ecshop

    问题一:商城首页报错 Strict Standards: Only variables should be passed by reference in D:wampecshopincludescls_template.php on line 422

    解决方法:

    找到提示错误的文件 cls_template.php 及行号

    把 $tag_sel = array_shift(explode(' ', $tag));

    改成:
    $tag_arr = explode(' ', $tag); 
    $tag_sel = array_shift($tag_arr);

    并且删除 D:wampwwwecshop empcaches下所有的文件

     

    问题二:后台首页报错 Strict Standards: Non-static method cls_image::gd_version() should not be called statically in D:wampwwwecshopincludeslib_base.php on line 346

    解决办法

    找到D:wampwwwecshopincludescls_image.php文件

    搜索 function gd_version 改成 static function gd_version

     

    问题三:后台-商店设置 

    Strict Standards: mktime(): You should be using the time() function instead in D:wampwwwecshopadminsms_url.php on line 31
    Strict Standards: mktime(): You should be using the time() function instead in D:wampwwwecshopadminshop_config.php on line 32

    解决办法

    根据错误提示 把 mktime() 改成 time()

     

    问题四:后台-起始页

    Strict Standards: Redefining already defined c**tructor for class alipay in D:wwwesincludesmodulespaymentalipay.php on line 85

    解决办法

    1)、错误原因:
    PHP 类,有两种构造函数,一种是跟类同名的函数,一种是 __contruct()。从PHP5.4开始,对这两个函数出现的顺序做了最严格的定义,必须是 __c**truct() 在前,同名函数在后

    2)、
    解决方法:
    调换一下两个函数的前后位置即可。
    以 includes/modules/payment/alipay.php  为例:
    将下面这两个函数的位置互换一下就OK了,__contruct()在前,alipay()在后

    1.    function alipay()    {
    2.     }
    3.  
    4.     function __contruct()
    5.     {
    6.         $this->alipay();
    7.     }


    3)、ECSHOP的很多类文件 都存在这个问题,都需要修改掉。

    问题五:后台-数据备份 

     Strict standards: Redefining already defined constructor for class cls_sql_dump in D:wampwwwecshopadminincludescls_sql_dump.php on line 90
    Strict standards: Non-static method cls_sql_dump::get_random_name() should not be called statically in D:wampwwwecshopadmindatabase.php on line 64

    解决办法

    根据错误提示 把 cls_sql_dump的 function __construct()改到  function cls_sql_dump()的前面

    把 cls_sql_dump的 function get_random_name()改成 static  function get_random_name()

     

    问题六:

    Deprecated: Assigning the return value of new by reference is deprecated in  adminsitemap.php on line 46

     $sm     =& new google_sitemap();

    解决办法

    在5.3版本之后已经不允许在程序中使用”=&”符号。如果你的网站出现了Deprecated: Assigning the return value of new by reference is deprecated in 错误,别着急,先定位到出错的文件,查找下是不是在程序中使用了”=&”,例如刚才定位到网站程序中发现了下图的程序,发现使用了”=&”符号,去掉‘&’符号之后程序运行正常

    问题七:

    Declaration of phpbb::set_cookie() should be compatible with integrate::set_cookie...

    解决办法:把function set_cookie ($username="") 改为function set_cookie ($username="", $remember = NULL)即可

     

    问题八:

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

    解决办法:

    我遇见了有两处,都在cls_template.php文件中:

     1、return preg_replace("/{([^}{ ]*)}/e", "$this->sel ect('\1');", $source);
    替换为
    return preg_replace_callback("/{([^}{ ]*)}/", function($r) { return $this->sel ect($r[1]); }, $source);
    问题解决。

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

      替换为

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

    问题解决

  • 相关阅读:
    CDH 2、Cloudera Manager的安装
    204 01 Android 零基础入门 03 Java常用工具类 04 Java集合 04 Map集合 01 Map概述
    203 01 Android 零基础入门 03 Java常用工具类 04 Java集合 03 Set集合 07 删除宠物猫信息数据(引入泛型知识点)
    202 01 Android 零基础入门 03 Java常用工具类 04 Java集合 03 Set集合 06 查找宠物猫信息数据
    201 01 Android 零基础入门 03 Java常用工具类 04 Java集合 03 Set集合 05 添加重复的宠物猫信息数据
    200 01 Android 零基础入门 03 Java常用工具类 04 Java集合 03 Set集合 04 添加和显式宠物猫信息
    199 01 Android 零基础入门 03 Java常用工具类 04 Java集合 03 Set集合 03 宠物猫信息管理概述
    198 01 Android 零基础入门 03 Java常用工具类 04 Java集合 03 Set集合 02 案例:在集合中插入字符串
    197 01 Android 零基础入门 03 Java常用工具类 04 Java集合 03 Set集合 01 Set概述
    196 01 Android 零基础入门 03 Java常用工具类 04 Java集合 02 List集合 05 案例:公告的删除和修改
  • 原文地址:https://www.cnblogs.com/F4natasy/p/7115631.html
Copyright © 2020-2023  润新知