我收到错误。你能看一下吗?我坐在上面,无法想象。 ExtendedEmailer是第二个子类。当我更改更改呼叫时编辑它工作..我可以回复发件人...但现在gettin gFatal错误:调用未定义的方法Extendedemailer :: sendHTMLEmail()
致命错误:调用未定义的方法HtmlEmailer :: setSender()
$a = new HtmlEmailer("asdada");
$a->setSender("asdad");
$a->addRecipients("asdad");
$a->setSubject("asdaasdadd");
$a->setBody("qweqwe");
$a->sendHTMLEmail();
这就是我设置发件人的地方
class.extendedemailer.php
class Extendedemailer extends emailer
{
function __construct(){}
public function setSender($sender)
{
echo $sender;
$this->sender = $sender;
}
}
class.htmlemailer.php
class HtmlEmailer extends emailer
{
public function sendHTMLEmail()
{
foreach ($this->recipients as $recipient)
{
......
if($result) echo "HTML successfully sent to {$recipient}<br/>";
}
}
}
index.php
class emailer
{
protected $sender;
protected $recipients;
private $subject;
private $body;
function __construct($sender)
{
$this->sender = $sender;
}
答案 0 :(得分:0)
setSender()在Extendedemailer类中实现,而不是在HtmlEmailer中实现。 另外 - 在php7 / phpng中,作为静态方法调用非静态方法已被弃用,您应该停止使用它。