as of PHP 5 PHP object variable contain the reference or identifier to the actual variable. here is an example to demonstrate this.
class test{ public $test = 1; } $obj1 = new test; $orginal = [$obj1,array(2),3]; $copy = $orginal; echo 'orginal array'; var_dump($orginal); echo 'copy of orginal'; var_dump($copy); //after changing $copy[0]->test = 'changed'; $copy[1][0] = 'changed'; $copy[3] = 'changed'; echo 'orginal array after changing its copy'; var_dump($original); echo 'copy of orginal after changing'; var_dump($copy);
the output for this is
original array array (size=3) 0 => object(test)[38] public 'test' => int 1 1 => array (size=1) 0 => int 2 2 => int 3 copy of original array (size=3) 0 => object(test)[38] public 'test' => int 1 1 => array (size=1) 0 => int 2 2 => int 3 original array after changing its copy array (size=3) 0 => object(test)[38] public 'test' => string 'changed' (length=7) 1 => array (size=1) 0 => int 2 2 => int 3 copy of original after changing array (size=3) 0 => object(test)[38] public 'test' => string 'changed' (length=7) 1 => array (size=1) 0 => string 'changed' (length=7) 2 => string 'changed' (length=7)
when the object in the copy is changed then the original object is also changed but the array and variable remain unchanged since they are passed as value.
more info about object reference refer : Objects and reference