I write some code:
class A {
private $x = 1;
private $y = "z";
public function setX($x){
$this->x = $x;
}
public function getX(){
return $this->x;
}
}
$a1 = new A();
$a1->setX(2);
echo $a1->getX();
$a2 = $a1;
$a2->setX(666);
echo $a1->getX();
I have output:
2
666
But I set value "666" only for object $a2.
Why value in $a1 changed too?
(OS: Ubuntu 10.04, PHP 5.3.2-1)