Who can explain why this returns an error:
$test = new myclass();
class myclass {
private $object = (object) NULL;
public function addmember() {
$this->object->member1 = 'member 1';
}
}
$test -> addmember();
... and this is OK:
$test = new myclass();
class myclass {
private $object = '';
public function addmember() {
$this->object = (object) NULL;// new stdClass();
$this->object->member1 = 'member 1';
}
}
$test -> addmember();
But why? Who can explain why the first example is wroing? Why I have to put the line with "(object)NULL" IN the function?