The addRecipients use push_array but it does not work. What am I doing wrong here??
In class.emailer.php
class Emailer
{
public $sender;
public $recipien
You need to call the parent's constructor from ExtendedEmailer's constructor.
class ExtendedEmailer extends emailer
{
function __construct(){
parent::__construct(null);
}
// ...
}
otherwise $recipients
is never initialized as an array.
You've missed to the call the parent constructor in the child's constructor
class ExtendedEmailer extends emailer
{
function __construct(){
//overwriting __contruct here
parent::__construct('dummy_sender@sender.com');
}
}
should fix this issue.
in file "class.emailer.php" just do
public $recipients = array();
instead of just the kinda naked
public $recipients;
That's all, and as a sur-plus, you're free to fill up your constructors as you desire. - What do you think about that?
Regards, M.
The problem is that you're overriding the Email
class's constructor and never calling it (parent::__construct()
). Either call the parent constructor in the ExtendedEmailer
class constructor, or remove the constructor altogether from ExtendedEmailer
if you're not actually using it (which in your sample code, you're not).
You are probably not initiating $recipients
when you rewrote the constructor.
class Emailer {
public $recipients = array();
function __construct($sender)
{
$this->sender = $sender;
}
Should do it. Check your warnings for
Warning: array_push() expects parameter 1 to be array, null given in ...