One of my colleagues made a post that said something like this:
In PHP, if you have two variables referring to the same value, they are the same instance.
$a="Mary";
$b="Mary";
$c="lamb"
He implies that $a and $b refer to the same instance(memory space). I am having trouble beleiving this. I know that this is somewhat true in java, but I don't think its so for php, since in php strings aren't actually immutable by principle, it would not make sense to have one instance
Further,he said, if we do unset($a)
it only removes the reference of $a not the actual value.
This is ofcourse true, but proves nothing
I also tried the following code and printed both $a and $b. If they were sharing the same instance, the value of $b would have changed too.
$a[2]=3;
echo "<br/>\$a: $a<br/>"; //He3lo
echo "<br/>\$b: $b<br/>";//Hello
I would love to check the memory space of the variables, but I don't think php allows to do that. Can somebody clarify if this is true