Using array_push in method in php

前端 未结 5 1834
抹茶落季
抹茶落季 2021-01-22 05:38

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         


        
5条回答
  •  灰色年华
    2021-01-22 06:43

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

提交回复
热议问题