Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60412 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49802 invoked from network); 2 May 2012 05:28:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 May 2012 05:28:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=laruence@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=laruence@gmail.com; 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:47298] helo=mail-lpp01m010-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B5/91-38165-716C0AF4 for ; Wed, 02 May 2012 01:28:56 -0400 Received: by lahl5 with SMTP id l5so171094lah.29 for ; Tue, 01 May 2012 22:28: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=8ey/0vtjM6Dm2LtOQ3kGKZS25CfLQmP1V+d6pi+y9sU=; b=RkaI+YtH1VzKqY/pi7aEdqVt5uoyx6VoT0ulR4Bs9WelKPndCARqGu8pYsHK0XEioL AJ0ger6k+6BpK5avvZQw9NdrYGqJ/z3MkFDyD5NBrhrGibvACSgZtJC40YZdkxDGlLaZ wr/UXAidRJBxDtiNBpCLrYdEu0i+ywp6QsXHDK1rNezx3fjdVnowcGDOEqL6yD/mIdER 0vpb3qbWadC5/p+j3SGcJTktEXxK3YFQRVmybDsxJqE1evfo4tRbZsRG+6fP1gS50l0F w6izSYlp6UKbuv1+jVN4rU6yldptCGqPaZksiNOZ50VqreGrN30QxpxC7IUaaVndqgCz 8o0g== Received: by 10.112.28.10 with SMTP id x10mr12956514lbg.41.1335936532950; Tue, 01 May 2012 22:28:52 -0700 (PDT) MIME-Version: 1.0 Sender: laruence@gmail.com Received: by 10.112.20.73 with HTTP; Tue, 1 May 2012 22:28:32 -0700 (PDT) In-Reply-To: References: Date: Wed, 2 May 2012 13:28:32 +0800 X-Google-Sender-Auth: NZpxd30helffMGRJESXuwx7Cz9c 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) 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 instan= ce >>> 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 ca= ll 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 custom >> 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 F= oo >> 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/ --=20 Laruence =C2=A0Xinchen Hui http://www.laruence.com/