Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60411 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48553 invoked from network); 2 May 2012 05:28:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 May 2012 05:28:08 -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.217.170 as permitted sender) X-PHP-List-Original-Sender: laruence@gmail.com X-Host-Fingerprint: 209.85.217.170 mail-lb0-f170.google.com Received: from [209.85.217.170] ([209.85.217.170:37979] helo=mail-lb0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9B/41-38165-7E5C0AF4 for ; Wed, 02 May 2012 01:28:08 -0400 Received: by lbgc1 with SMTP id c1so174515lbg.29 for ; Tue, 01 May 2012 22:28:04 -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=fP2nb1M2MqHV9ds0hfYjzt5hTfa7K9dTHcTmbTcsGaE=; b=RU5XW9f5cnyS38gMpBFv2wXmRren2EWisGBDhIY2cfa2+2RinfQwhBmm/nusQxfyjT iPYoHbcb4rP5Y5JAFHPecAy8khYe2Zu91EyrzQir1Ek06AtL8J6PzgFNmxYLNNxDoEpJ Tw4EsaGUg1bOFSqih34elrPCWhLyAVLdoYPhitVOcWmPvOJ7HxDNbW9FsUhBXodw/u3H +90hc9K+/FiO1o48R5KmIhcWXfVAWQHc7X5oNX0kG5rvr00GxB4izX1uBjZ790txb8jQ 7Stu0RPkU0ikIEAS5GkDLz44h2Ciwk26+AItnQip/E8zaoElTOhCdIsfr4jEsRT0cI2L S6LQ== Received: by 10.112.28.10 with SMTP id x10mr12955634lbg.41.1335936484318; Tue, 01 May 2012 22:28:04 -0700 (PDT) MIME-Version: 1.0 Sender: laruence@gmail.com Received: by 10.112.20.73 with HTTP; Tue, 1 May 2012 22:27:43 -0700 (PDT) In-Reply-To: References: Date: Wed, 2 May 2012 13:27:43 +0800 X-Google-Sender-Auth: Nn7icFj2yEs9IoWyCdlykzTIqcM 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: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 instanc= e >> 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 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 Fo= o > 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 --=20 Laruence =C2=A0Xinchen Hui http://www.laruence.com/