Re: serialize bug with array that references to itself?
| From: | Andrey Hristov | Date: | Wed, 03 Nov 2004 17:25:45 +0000 |
| Subject: | Re: serialize bug with array that references to itself? | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-13715@lists.php.net to get a copy of this message | ||
Hi,
print_r() and var_dump() are quite different in their nature.
print_r() is a thin wrapper around an internal Zend function
(as far as I remember) while var_dump() is in ext/standard/var.c
The do more or less the same job still some differences in the
output (print_r() shows nothing on NULL variables which I find
clumsy since lack of output where I expect ouput makes me
suspicious).
Andrey
Jochem Maas wrote:
Andrey Hristov wrote:Well, when there is traversion inside the engine, it checks whether it has processed a "node" already several times. As far as I remember the threshold is 3. So once it goes over $Arr, the counter increases to 1, the second time to 2 and third time it is 3 and ZE reports recursion.is there good reason to set the threshold at 3 iso 2? when dumping out objects that make heavy use of 'parent' references this leads to tons of extra output which would be greatly cutdown if the threshold was 2 iso 3. just to make the point, print_r seems to use a threshold of 2 (which is why I always try print_r before taking my chances with var_dump): <?php class a { public $self; } $A = new a; $A->self = $A; var_dump( $A ); print_r( $A ); ?>HTH, Andrey Francisco M. Marzoa Alonso wrote:BTW., I'm not sure that there's nothing more wrong here. Takin the first part of the code of first example: <?php $Arr = array(); $Arr['self'] = &$Arr; var_dump ( $Arr ); ?> It returns: array(1) { ["self"]=> array(1) { ["self"]=> *RECURSION* } } Is that as its expected to be? I meant that perhaps it should be: array(1) { ["self"]=> *RECURSION* } Since the element in $Arr['self'] is yet (or at least should be) a reference to itself...