Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:12000 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18644 invoked by uid 1010); 8 Aug 2004 12:37:18 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 18610 invoked from network); 8 Aug 2004 12:37:17 -0000 Received: from unknown (HELO jan.prima.de) (83.97.50.139) by pb1.pair.com with SMTP; 8 Aug 2004 12:37:17 -0000 Received: from BAUMBART (p508EA483.dip.t-dialin.net [::ffff:80.142.164.131]) (IDENT: HydraIRC, AUTH: LOGIN tobi) by jan.prima.de with esmtp; Sun, 08 Aug 2004 12:34:38 +0000 Date: Sun, 8 Aug 2004 14:37:14 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <1339876739.20040808143714@marcus-boerger.de> To: Ron Korving CC: internals@lists.php.net In-Reply-To: <20040808111514.43930.qmail@pb1.pair.com> References: <20040808022353.GG6522@bagend.shire> <20040808111514.43930.qmail@pb1.pair.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: objects passed as reference in php5 From: helly@php.net (Marcus Boerger) Hello Ron, that's prefectly correct. regards marcus Sunday, August 8, 2004, 1:14:55 PM, you wrote: > i think the object will only cease to exist when all references to it are > gone > "Curt Zirzow" wrote in message > news:20040808022353.GG6522@bagend.shire... >> >> I'm trying to document how objects are passed to functions in php5, >> but am running into some troubles. >> >> In the code below the object appears to be a reference but when the >> original object is destoyed it still somehow exists. Can someone >> explain how this is? I was going to report a bug on this but using >> the traditional &$obj usage it works perfectly fine. >> >> class Test { >> public $object = null; >> public $object1 = null; >> >> >> function SetVarVal($obj) { >> $this->object = $obj; >> } >> >> function SetVarRef(&$obj) { >> $this->object1 = &$obj; >> } >> >> } >> >> $obj1 = new StdClass(); >> >> $obj2 = new Test(); >> $obj2->SetVarVal($obj1); >> $obj2->SetVarRef($obj1); >> >> >> $obj1->foo = 'test'; /* show how obj1's is a ref */ >> $obj1 = null; /* destroy object */ >> >> var_dump($obj2->object); /* still has object with ->foo */ >> var_dump($obj2->object1); /* NULL */ >> >> >> >> Curt >> -- >> First, let me assure you that this is not one of those shady pyramid > schemes >> you've been hearing about. No, sir. Our model is the trapezoid! -- Best regards, Marcus mailto:helly@php.net