> I really can't see why you'd want to use references in the posted
> loop anyway -- it's not likely to gain you any performance, and, as
> I understand it, may actually run more slowly than the
> non-reference version.

The why is irrelevant. It is perfectly legal PHP, and while it might be 
illegal usage of DOMNode, it should only break the DOMNode, and not PHP 
execution environment.

> I don't think it's possible to answer this for sure without seeing more of
> the code -- at least the complete body of the loop, plus as far as any
> further use of the variable $child (and any other variables assigned from
> it).

OK, I modified the example to show the problem _very_ directly. I commented out 
the recursion-tracing echos, and added this code in renderObject() below the 
if() that chooses between the good and evil loop, which means that the added 
code is always executed immediately after the loop:

        echo "\n";

Note that these variables:

 - are first defined at this point
 - are initialized immediately
 - are initialized with immediate data (empty array and two scalars), not
   with results of prior computation
 - are never used or changed except for being dumped
 - don't get any references to them created

Therefore one must expect that var_dump will always dump this:

array(0) {         
string(1) "y"      

However it sometimes dumps this:


Best regards,
Szczepan Holyszewski

<<attachment: testme.php>>

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

Reply via email to