In PHP, I have this simple class
<?php
class Person {
var $first_name = "factory method";
}
?>
The question I have is if I have:
$person1 = new Person();
$person2 = $person1;
$person1 = null;
var_dump($person1);
var_dump($person2);
what I get is: both $person1 = null and $person2 is not null at all, it seems $person1 and $person2 are not pointing to the same thing at all.
but when I do something like below:
$person1 = new Person();
$person2 = $person1;
$person2->first_name = "programming";
echo $person1->first_name;
echo $person2->first_name;
I got the same thing "programming", so I think the both $person1 and $person2 are pointing to the same thing.
Could someone explain to me why is it like that?