Re: Re: Help on zend_hash_update
| From: | Gustavo Badauy | Date: | Thu, 24 Aug 2000 15:44:22 +0000 |
| Subject: | Re: Re: Help on zend_hash_update | ||
| References: | 1 2 3 4 5 6 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-30524@lists.php.net to get a copy of this message | ||
Acctually what I wanted to do is what is described in PHP3 Appendix A
manual. Which is, inside an extension create an object and add some methods
to it.
Let's say from a PHP page do that
$myvar = myfunction(); // myfunction returns an object
$myvar->a_method_created_inside_the_extension();
Gustavo
> ----- Original Message -----
> From: "Sterling Hughes" <sterling@php.net>
> To: "Andrei Zmievski" <andrei@ispi.net>
> Cc: "Gustavo Badauy" <gbadauy@yahoo.com>; "php-dev"
<php-dev@lists.php.net>
> Sent: Wednesday, August 23, 2000 9:02 PM
> Subject: Re: [PHP-DEV] Re: Help on zend_hash_update
>
>
> >
> >
> > > On Wed, 23 Aug 2000, Sterling Hughes wrote:
> > > > If you mean how to create an object with methods? Look at
> > > > ext/standard/dir.c.
> > > >
> > > > Its simple, every class has a function table, simply create your
> > function
> > > > table and then use the INIT_CLASS_ENTRY macro. example:
> > > >
> > > > static zend_class_entry *yourmod_ce_ptr;
> > > >
> > > > static function_entry php_yourmod_class_functions[] = {
> > > > PHP_FE(meth1, NULL)
> > > > PHP_FE(meth2, NULL)
> > > > };
> > > >
> > > > PHP_MINIT_FUNCTION(yourmod)
> > > > {
> > > > zend_class_entry yourmod_ce;
> > > >
> > > > INIT_CLASS_ENTRY(youmod_ce, "YourMod",
> php_yourmod_class_functions);
> > > > yourmod_ce_ptr = zend_register_internal_class (&yourmod_ce);
> > > > }
> > > >
> > > > PHP_FUNCTION(init_function)
> > > > {
> > > > object_init_ex(return_value, yourmod_ce_ptr);
> > > > /* add properties you want, etc. */
> > > > }
> > >
> > > I think he meant adding methods to existing classes.
> > >
> >
> > To do that couldn't you just insert entries in to the object's
> > function_table (which is a 'HashTable').
> >
> > Sterling
>
>
>