note 27894 deleted from migration4.variables by danbrown
| From: | danbrown@php.net | Date: | Fri, 28 Nov 2008 21:26:51 +0000 |
| Subject: | note 27894 deleted from migration4.variables by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-147242@lists.php.net to get a copy of this message | ||
Note Submitter: brooke at jump dot net
----
Better (and likely more correct) way to look at it is this:
In php3, the global statement caused named variables to become aliases. In php4, the global
statement constructs references. In php3, there are no references. In php4, references are what get
unset, not the pointed-to values. The same change affects function parameters passed by reference.
In php3, you got aliases. In php4, you get references. If you unset a reference, then you've
lost only the reference. The original variable remains.
function foo(&$bar) {
unset($bar);
$bar = 27;
}
$x = 5;
foo($x);
assert($x == 5);