Re: References - good or bad
| From: | ira at crosswinds dot net | Date: | Sun, 18 Aug 2002 04:59:36 +0000 |
| Subject: | Re: References - good or bad | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-86995@lists.php.net to get a copy of this message | ||
Hi,
I've read "PHP 4: Reference Counting and Aliasing" By Andi Gutmans on Zend.com site
(http://www.zend.com/zend/art/ref-count.php). Also I read this mail http://marc.theaimsgroup.com/?l=php-dev&m=100955714924477
from him.
I would like to know more about how reference is managed by PHP4. I'm missing something like
that article (see the first URL) for reference.
What happens inside PHP4 with this code ?
<?
$a = 5;
$b = $a;
$c = &$b;
$d = $c;
?>
How PHP4 know that $c and d are reference to $a and not "counted" like $b ? And so what
makes references so bad ? ;-)
Another (more important) example:
<?
function foo( $msg )
{
$tmp = &$msg;
return $tmp;
}
?>
What happens to $tmp ? If it will not refer to a new memory block why the memory used by the script
is more than without '&' ? (See the second URL).
Thanks.
Ed
___________________________________
Build high quality traffic with the Web's Premier traffic building system. 2 to 1 ratio! http://www.itrafficstar.com/?ref=6