Re: Re: how to instantiate new object

From: Date: Wed, 02 May 2012 09:30:52 +0000
Subject: Re: Re: how to instantiate new object
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-60416@lists.php.net to get a copy of this message
On Wed, 2012-05-02 at 13:27 +0800, Laruence wrote: > On Wed, May 2, 2012 at 1:16 PM, Yader Hernandez > <yader.hernandez@gmail.com> wrote: > > On Tue, May 1, 2012 at 8:46 PM, Yader Hernandez > > <yader.hernandez@gmail.com>wrote: > > > >> Hello, > >> > >> I was wondering how to create a new object from a function call? > >> > >> By this I mean if I call foo() from a script, that should return a new > >> instance of an object. If I call foo() again, it should be a new instance > >> of an object as well. > >> > >> I haven't been able to find any good examples from the code I've been > >> reading. > Hi: > > MAKE_STD_ZVAL(instance); > object_init(instance , class_entry_ce); > > and if you want to call the contructor, you have to call it explicitly. > > see: http://lxr.php.net/opengrok/xref/PECL/yaf/views/simple.c#216eAô¸ > Òî«HW#—$ßÉ This doesn't seem to run the ctor. Full example is ZEND_METHOD(reflection_class, newInstance) http://lxr.php.net/opengrok/xref/PHP_5_4/ext/reflection/php_reflection.c#4092 johannes

« previous php.internals (#60416) next »