I have class
class User extends BaseModel{
public $id;
public $name;
}
class BaseModel{
function __construct($data=null){
if($data!=null)
//set $id and $name
}
}
I would like to set $id , $name and any other data that extends BaseModel by calling
$test = new User(array('id'=>1,'name'=>'user name'))
I tried to use
$this->__set($arrayKey,$arrayValue);
But i got error : Fatal error: Call to undefined method User::__set() What am I doing wrong? Thank you for any help.