Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60413 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51063 invoked from network); 2 May 2012 05:29:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 May 2012 05:29:56 -0000 Authentication-Results: pb1.pair.com header.from=laruence@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=laruence@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.42 as permitted sender) X-PHP-List-Original-Sender: laruence@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-lpp01m010-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:63198] helo=mail-lpp01m010-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B3/E1-38165-356C0AF4 for ; Wed, 02 May 2012 01:29:56 -0400 Received: by lahl5 with SMTP id l5so171524lah.29 for ; Tue, 01 May 2012 22:29:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=bD5riMYDvWVMA9zJqgwu27WM2qh+ZAArQoT4gHtt8Xk=; b=QEV8Ai+mHa7iAa/bUPe5+OtJgmgVJKjAM7jN1Z57X4yuOotcnOaeGBG/LngkeYiQvx IAsbI1l4qMS2xudQEv5XNgHXJE2rQOwl8TzZMSA1Gmdq/aspO5eOzHRG8EEPVbgDCwuk RMfLGceCvfw6UnXSWc+Acjz3NMuHvZgvf7YKxl8oiGRTXU50TQt2ZHxxT84MI6LdaBVz Tw1275/rd9txGPXi3jItrt4s0SgPDiCnChv1WW1lPwBbi+R7/e2GuQows5T9hnMbDeVW zRgn6nYIkLc6SbQbrewVhgERKAaFSLPdjMMbPk5+krnLgd0AEV57Tzbn7hKCs9soOnBX XNJw== Received: by 10.112.51.225 with SMTP id n1mr3162090lbo.27.1335936593107; Tue, 01 May 2012 22:29:53 -0700 (PDT) MIME-Version: 1.0 Sender: laruence@gmail.com Received: by 10.112.20.73 with HTTP; Tue, 1 May 2012 22:29:32 -0700 (PDT) In-Reply-To: References: Date: Wed, 2 May 2012 13:29:32 +0800 X-Google-Sender-Auth: YoW1-CwtdrLFhRpyjvae4lbEANU Message-ID: To: Yader Hernandez Cc: PHP Developers Mailing List Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Re: how to instantiate new object From: laruence@php.net (Laruence) BTW: you should write to pecl-dev ML for such questions. thanks On Wed, May 2, 2012 at 1:28 PM, Laruence wrote: > On Wed, May 2, 2012 at 1:27 PM, 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 insta= nce >>>> of an object as well. >>>> >>>> I haven't been able to find any good examples from the code I've been >>>> reading. >> Hi: >> >> =C2=A0 =C2=A0MAKE_STD_ZVAL(instance); >> =C2=A0 =C2=A0object_init(instance , class_entry_ce); > typo, should be object_init_ex. > > thanks >> >> =C2=A0 =C2=A0and if you want to call the contructor, =C2=A0you have to c= all it explicitly. >> >> =C2=A0 see: http://lxr.php.net/opengrok/xref/PECL/yaf/views/simple.c#216 >> >> thanks >> >> >>>> >>>> Does anyone know of a good place to find an example? >>>> >>>> thanks >>>> >>> >>> To be a little clearer I mean that in my extension, I can call my custo= m >>> object. So any calls from a script will be able to do $o =3D new Foo().= I >>> registered my struct in zend_objects_store_put, so I understand how the >>> instantiate is happening. >>> >>> But now I'm implementing a ZEND_METHOD that requires a new instance of = Foo >>> and I've been stuck for a few days trying to find a nice clean example. >>> >>> I was wondering if someone knew of a good place look into? >>> >>> thanks >> >> >> >> -- >> Laruence =C2=A0Xinchen Hui >> http://www.laruence.com/ > > > > -- > Laruence =C2=A0Xinchen Hui > http://www.laruence.com/ --=20 Laruence =C2=A0Xinchen Hui http://www.laruence.com/