This section describes what is in an object variable - An object variable actually contains the object identifier that points to where the object is stored.
What Is in an Object Variable?
An object variable actually contains the object identifier that points to where the object is stored.
Don't confuse object variables with variable references. They are totally different concepts. If they are used
together with objects, you should expect the following behaviors:
The content of an object variable, $a, is an identifier to an object
When assigning a variable $a to a new variable $b, using ($b = $a),
the content of $a is copied to $b as $b's content.
If $a's content is an identifier to an object, $b's content is copy of the same identifier to the same object.
A variable reference, &$x, returns an alias to the original variable.
When assigning a variable reference &x to a new variable $y using ($y = &$x),
the new variable become an alias in the alias group of original variable.
All aliases are sharing the same content.
To help us understand the relations of objects, identifiers, variables and references,
let's consider the following PHP code:
$a = new C();
$b = $a;
$x = new C();
$y = &$x;
$z = &$y;
$o = $z;
After execution, we should have the following in memory: