Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:43133 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37429 invoked from network); 20 Feb 2009 22:45:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Feb 2009 22:45:54 -0000 X-Host-Fingerprint: 66.153.171.97 rcs.us Received: from [66.153.171.97] ([66.153.171.97:15782] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 09/41-28577-2A23F994 for ; Fri, 20 Feb 2009 17:45:54 -0500 Message-ID: <09.41.28577.2A23F994@pb1.pair.com> To: internals@lists.php.net Date: Fri, 20 Feb 2009 17:45:51 -0500 User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 References: <402EC0719ACD453B94A252DB2DEA8829@dmp.home> In-Reply-To: <402EC0719ACD453B94A252DB2DEA8829@dmp.home> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 66.153.171.97 Subject: Re: Adding a property to an object From: mrice@rcs.us ("Matthew C. Rice") David, I personally have not read that book, as I actually heard pertaining to objects ( where I too have had some issues ) it wasn't really a terrific reference. Though if this is not the case, I would love to hear otherwise.. I don't know if this is the "right" way, but a way to go about doing what you want can be done in the PHP_MINIT_FUNCTION() with something like zend_declare_property_string(zend_class_entry* ce, char* name, int name_length, char* value, ZEND_ACC_PRIVATE); Matthew C. Rice David M. Patterson wrote: > Hello all. > > > > I am attempting to convert one of my extensions to OOP. > I have a class entry and (I think) I've instantiated an instance of it > within RINIT(). > What I haven't been able to do is add a private property to it. > > I have the Goleman book and followed the information on pages 148 and 149, > to no avail. The book says to call zend_mangle_prooperty_name() specifying > the class name as the class name argument. > It always fails with "Could not startup." > Stepping through with the debugger I find: > - zend_mangle_property_name() has worked as described in the book. The > property name is \0class\0prop\0. > - add_property_double_ex() fails. Actually, the failure is in > _zend_property_info() when it explicitly checks the first character of the > passed property name for a null and fails if it is. > > Searching lxr.php.net hasn't helped so far. > > > > Suggestions or a pointer to code that is actually doing this would be great. > By the way, I'm using PHP 5.2.8. > > Thanks, > > Dave > >