When I store object to a session in PHP 5.3 and then trying to change its properties they also changed in session array. Why it so? Explain me please!
My code:
<?php
class Z {
public $val;
}
session_start();
$z = new Z();
$z->val = 10;
$_SESSION['z'] = $z;
$z->val++;
print_r($_SESSION);
?>
Result:
Array ([z] => Z Object ( [val] => 11 ) )