MY_Email :: initialize()的声明应与CI_Email :: initialize()的声明兼容

时间:2018-09-26 02:32:29

标签: php codeigniter phpmailer

    public class CoinJsonWrapper {

    @SerializedName("code")
    private String code;

    @SerializedName("codein")
    private String codein;

    @SerializedName("name")
    private String name;

    @SerializedName("high")
    private Float high;

    @SerializedName("low")
    private Float low;

    @SerializedName("ask")
    private Float ask;

    @SerializedName("timestamp")
    private Long timestamp;

    @SerializedName("create_date")
    private String create_date;

    public final String get_code() {
        return this.code;
    }

    public final String get_codein() {
        return this.codein;
    }

    public final String get_name() {
        return this.code;
    }

    public final Float get_high() {
        return this.high;
    }

    public final Float get_low() {
        return this.low;
    }

    public final Float get_ask() {
        return this.ask;
    }

    public final Long get_timestamp() {
        return this.timestamp;
    }

     public final String get_create_date() {
        return this.create_date;
    }


}

文件:C:\ xampp \ htdocs \ e-com \ application \ controllers \ User_pannel_controller.php 线:478 功能:库

文件:C:\ xampp \ htdocs \ e-com \ index.php 线:315 功能:require_once

遇到错误 SMTP connect()失败。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

1 个答案:

答案 0 :(得分:0)

这意味着您的子类与父类不兼容。例如:

class CI_Email
{
    public function initialize($a, $b)
    {
        echo 'foo';
    }
}

class MY_Email extends CI_Email
{
    public function initialize($a)
    {
        echo 'bar';
    }
}

此代码将导致...should be compatible with...错误,因为如果将My_Email的实例替换为CI_Email,则会删除必需的参数$b

更改子类的initialize方法,使其包含与父类相同的所有参数。您可以添加其他可选参数,但不能删除它们,因此可以这样做:

public function initialize($a, $b, $c = 0) ...