Re: DOMNode children iteration (was Re: array() returns something weird)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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:

	$x=array();
	$y="y";
	$z=1;
	var_dump($xy,$y,$z);
	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"      
int(1)

However it sometimes dumps this:

NULL               
NULL               
NULL

Best regards,
Szczepan Holyszewski

Attachment: testme.php
Description: application/php

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

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux