just a little update after playing arround with this stuffs, 

I think this behavior happens when there is nothing else pointing to variable $a. 
so for example, this works also: 

$tmp =& $a;
$a =& $a->next; 

I'm wondering how php does garbage collection? does it immediately delete variables 
that have nothing pointing to it?

- reynard 

>I just found this behavior when trying to implement a linked list with php.
>In linked list it's common to say: 
>$a =& $a->next; 
>when traversing the list. but this doesn't work (it gives segmentation fault when 
>trying to access the $head->next object (after the above assignment). 
>but this work: 
>$tmp =& $a;
>$a =& $tmp->next; 
>I don't know if this can be considered a bug or if it's designed to work that way. 
>But I think it would be nice to be able to do it without creating temporary variable. 
>here is the full code. I'm using php 4.2.2 and I'm running the code from comand line. 
>(if I execute it from the web it gives something like 'document contains no data' 
>instead of segmentation fault)

The NEW Netscape 7.0 browser is now available. Upgrade now! 

Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to