Re: print_r unaware of object's read_property handler
| From: | Piotr Pokora | Date: | Thu, 15 Feb 2007 14:27:19 +0000 |
| Subject: | Re: print_r unaware of object's read_property handler | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-4532@lists.php.net to get a copy of this message | ||
antony@zend.com (Antony Dovgal) wrote:
> "Registering" properties in constructor? What a strange idea..
> Constructor usually constructs fully functional object, properties are declared along with the
> class itself.
Forgive me once again. Part of the concept comes from ZEND1 which segfaulted in such cases.
Use google to find problems with using default_properties and ZEND1.
I already know this approach is bad.
> > So "fails" means that property's value is not returned by print_r, though
> > read_property hook
> > seems to be ok as <?php echo $object->propA; ?> works fine.
>
> Sure, you didn't add the properties to the hash.
What read_property hook is used for? Return's property's zval?
Do you mind if I contribute and add something to ZEND2 docs?
"read_property - returns zval *, containing the value of the
property. Is used when value of the property should be retrieved for
reading.
Keep in mind that ZEND2 engine doesn't use always your own defined
read_property hook. Sometimes it uses only hash table returned by get_properties
hook. So if your extension requires object's property to be readable with every internal
function , you must implemement your own hooks that way , so they update object's
properties hash table. In other words it is not guaranteed, that your read_property hook
will be always used by ZEND2 engine."
Piotras