note 59562 rejected from language.references by gustavo
| From: | gustavo@php.net | Date: | Tue, 20 Dec 2005 03:25:29 +0000 |
| Subject: | note 59562 rejected from language.references by gustavo | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-100443@lists.php.net to get a copy of this message | ||
Note Submitter:
----
The comparison between unix filenames and the claim that PHP has garbage collection might mislead
you into thinking that variable data is kept in memory until it becomes inaccesible by any
reference. This would make the code
<?php
function example() {
global $bar;
$foo='hello!';
$bar =& $foo;
}
$bar='';
example();
echo $bar;
?>
output 'hello!'. Actually it outputs nothing! That's because the $foo is removed from
memory as soon as control leaves the function example(). The global reference $bar then points to an
undefined variable.
References are thus 'weak', they are not real references, just symbolic aliases. No
general-graph based garbage collection is performed.