Re: print_r unaware of object's read_property handler

From: Date: Fri, 16 Feb 2007 10:40:23 +0000
Subject: Re: print_r unaware of object's read_property handler
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-4553@lists.php.net to get a copy of this message
Piotr Pokora wrote: > get_properties_hook () > { > if(already_updated) { > return obj.properties > } else { > do update > return updated_hash > } > } You don't need to care about get_properties() performance, as it only happens for print_r() and var_dump() (mostly only used for debugging) and the array cast, either not used that often. The example you see (swish etc.) use the objects own properties hash because if we'd allocate a temporary hash by our own in get_properties() we'd leak that memory, because the engine doesn't destroy the hash, it expects you to keep an eye on it. This is why markus proposed a get_debug_info() object handler, see the archives @internals. So, Tony (and many others) use the properties hash for this purpose, because it is destroyed in the defined zend objects free routine. Userland never ever accesses the properties hash except through get_properties() in this approach. PS: Z_* macros are supposed to operate on zvals. Regards, -- Michael

« previous php.pecl.dev (#4553) next »