Is possible clone php object class and alway change all available
Example
Class A{
private $data;
public function set($name, $value){
$this->data[$name] = $value;
}
public function get($name){
return isset($this->data[$name]) ? $this->data[$name] : null;
}
public function __clone(){
$this->data = unserialize(serialize($this->data));
}
}
Working with clone
$a = new A();
$a->set('dog', 'Kiki');
$b = clone $a;
var_dump($b->get('dog'));
dump value is 'Kiki';
So i need object for $b alway change dynamic when object $a is change example
$a = new A();
$b = clone $a;
$a->set('dog','Kiki');
var_dump($b->get('dog'));
dump value is null;
how to change dynamic object $b when object $a change ?
Thanks