Re: Reading/Writing properties

From: Date: Mon, 30 Sep 2013 21:24:38 +0000
Subject: Re: Reading/Writing properties
References: 1  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-11140@lists.php.net to get a copy of this message
On Mon, 2013-09-30 at 21:12 +0200, Kevin Ingwersen wrote: > Hello there. > > I am trying to read/write properties. I have found the read_property > function as such: > > ZEND_API zval *zend_read_property(zend_class_entry *scope, zval > *object, const char *name, int name_length, zend_bool silent > TSRMLS_DC); > > But, what is a zend_bool? I trued passing false to it, but i got an > error O.o so I think I sort of missed this a bit. A zend_bool is an unsigned char, see zend_types.h. I think we don't have global true/false constants defined, so you can use 0 or 1 for false or true. But I'm not sure I understood your question correctly. Please always share some code and error messages. > I am essentially trying to store a resource into an object, and > reading it off in another member function. What exactly are you trying to achieve? Are you creating an internal class and want to store custom data (i.e. pointers to some library stuff) in it? Then don't mess with resources but extend the zend_object structure typedef struct { zend_object zo; /* has to be the first element */ void *ptr; /* custom members */ } my_object; See http://talks.somabo.de/200903_montreal_php_extension_writing.pdf slides 89-92. By overriding different property handlers these custom elements can be exported to userland in nice ways. johannes

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