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


A PHP Error was encountered
Severity: Runtime Notice
Message: Declaration of MY_Email::initialize() should be compatible with 
that of CI_Email::initialize()
Filename: libraries/MY_Email_3_1_x.php
Line Number: 1374
Backtrace:
File: C:xampphtdocse-comapplicationlibrariesMY_Email.php
Line: 17
Function: _error_handler
File: C:xampphtdocse-comapplicationlibrariesMY_Email.php
Line: 17
Function: require_once

文件: C:\xampp\htdocs\e-com\application\controllers\User_pannel_controller.php 行: 478 功能:图书馆

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

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

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

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) ...

相关内容

  • 没有找到相关文章

最新更新