PHP references allow you to make two variables to refer to the same content. Meaning, when you do:
<?php
$a =& $b;
?>
it means that $a and $b point to the same content.
Note: $a and $b are completely equal here, that's not $a is pointing to $b or vice versa, that's $a and $b pointing to the same place.
Unsetting References
When you unset the reference, you just break the binding between variable name and variable content. This does not mean that variable content will be destroyed. For example:
<?php
$a = 1;
$b =& $a;
unset($a);
// OR
$a = 1;
$b =& $a;
$b = NULL;
?>
won't unset $b, just $a.
Again, it might be useful to think about this as analogous to Unix unlink call.
$thisIn an object method, $this is always a reference to the caller object.
No comments:
Post a Comment