Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13719 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42347 invoked by uid 1010); 3 Nov 2004 18:35:18 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 42316 invoked from network); 3 Nov 2004 18:35:17 -0000 Received: from unknown (HELO mx1.moulin.nl) (194.109.193.120) by pb1.pair.com with SMTP; 3 Nov 2004 18:35:17 -0000 Received: from localhost (localhost [127.0.0.1]) by mx1.moulin.nl (Postfix) with ESMTP id 954718A18B; Wed, 3 Nov 2004 19:35:22 +0100 (CET) Received: from mx1.moulin.nl ([127.0.0.1]) by localhost (moulin [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 01821-05; Wed, 3 Nov 2004 19:35:20 +0100 (CET) Received: from [10.0.5.5] (ip51cf8e8c.direct-adsl.nl [81.207.142.140]) by mx1.moulin.nl (Postfix) with ESMTP id 0C8448A18A; Wed, 3 Nov 2004 19:35:20 +0100 (CET) Message-ID: <418924E2.9050603@iamjochem.com> Date: Wed, 03 Nov 2004 19:35:14 +0100 User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-gb, en-us, en, nl MIME-Version: 1.0 To: Andrey Hristov Cc: internals@lists.php.net References: <4188DEC8.5060309@gmx.net> <4188DDC9.30000@hristov.com> <4189013F.2050104@gmx.net> <4188F4CC.6000902@hristov.com> <41890B41.5020703@gmx.net> <41890169.1020107@hristov.com> <4189094F.10105@iamjochem.com> <41891499.7080007@hristov.com> In-Reply-To: <41891499.7080007@hristov.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at moulin.nl Subject: Re: [PHP-DEV] serialize bug with array that references to itself? From: jochem@iamjochem.com (Jochem Maas) Hi Andrey, I have to confess my understanding of the engine internals is next to zero, but I do understand that var_dump and print_r were created with/for different pretexts. I agree with you that printing nothing for NULL is doesn't feel right (btw boolean false has the same effect) - this can be problematic when you don't know that this is the case (indeed much time have I lost on this issue when I first started out), this is a minor gripe and easily sidestepped with a var_dump :-) my question was more out of curiosity (although I would like to see the threshold for var_dump dropped to 2 if that is technically feasible/acceptable) - there may be a good reason for the difference in thresholds, it may be a an oversight/inconsistency. either way my motive is to better understand the reasoning behind the way things work in PHP - better understanding how/why a developer made it work a certain has in the past really helped me improve my code. thanking everyone who has made (and continues to make) PHP what it is - it rocks alot more than it doesn't ;-). Andrey Hristov wrote: > 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): >> >> > >> 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: >>>> >>>> >>> >>>> $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... >>>> >>> >> >