Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60416 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70887 invoked from network); 2 May 2012 09:30:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 May 2012 09:30:58 -0000 Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 217.114.211.66 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 217.114.211.66 config.schlueters.de Received: from [217.114.211.66] ([217.114.211.66:35872] helo=config.schlueters.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2C/D4-38165-0DEF0AF4 for ; Wed, 02 May 2012 05:30:57 -0400 Received: from [192.168.2.230] (ppp-88-217-94-105.dynamic.mnet-online.de [88.217.94.105]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by config.schlueters.de (Postfix) with ESMTPSA id D07266189C; Wed, 2 May 2012 11:30:53 +0200 (CEST) To: Laruence Cc: Yader Hernandez , PHP Developers Mailing List In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Date: Wed, 02 May 2012 11:30:52 +0200 Message-ID: <1335951052.2696.35.camel@guybrush> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: how to instantiate new object From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) On Wed, 2012-05-02 at 13:27 +0800, Laruence wrote: > On Wed, May 2, 2012 at 1:16 PM, Yader Hernandez > wrote: > > On Tue, May 1, 2012 at 8:46 PM, Yader Hernandez > > 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#216 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