Creating references within the constructor can lead to confusing
results. This tutorial-like section helps you to avoid problems.
Let us check out if there is a difference between
$bar1 which has been created using
the copy = operator and
$bar2 which has been created using
the reference =& operator...
Apparently there is no difference, but in fact there is a
very significant one: $bar1 and
$globalref[0] are _NOT_ referenced, they
are NOT the same variable. This is because "new" does not
return a reference by default, instead it returns a copy.
Poznßmka:
There is no performance loss (since PHP 4 and up use reference
counting) returning copies instead of references. On the
contrary it is most often better to simply work with copies
instead of references, because creating references takes some
time where creating copies virtually takes no time (unless none
of them is a large array or object and one of them gets changed
and the other(s) one(s) subsequently, then it would be wise to
use references to change them all concurrently).
To prove what is written above let us watch the code below.
Another final example, try to understand it.