未定义的方法OOP和PHP


undefined method OOP and PHP

我收到错误。你能看一下吗?我坐在上面想不通。ExtendedEmailer是第二个子类。当我更改更改调用时进行编辑它有效。。我可以回显发送器。。。但现在出现gFatal错误:调用未定义的方法ExtendedMailer::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;  
 }

setSender()是在ExtendedMailer类中实现的,而不是在HtmlEmailer中实现的。此外,在php7/phpng中,不赞成将非静态方法作为静态方法调用,您应该停止使用它