What References Are Not
What References Are Not
As said before, references are not pointers. That means, the
following construct won't do what you expect:
<?php
function foo(&$var)
{
$var =& $GLOBALS["baz"];
}
foo($bar);
?>
What happens is that in
will be bound with
in the caller, but then
re-bound with . There's no way
to bind in the calling scope to something else
using the reference mechanism, since is not
available in the function (it is represented by
, but has only
variable contents and not name-to-value binding in the calling
).
You can use to reference variables selected by the function.
$var``foo``$bar``$GLOBALS["baz"]``$bar``$bar``foo``$var``$varsymbol tablereturning
references