Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:10807 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19086 invoked by uid 1010); 28 Jun 2004 09:18:50 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 40973 invoked from network); 28 Jun 2004 09:08:09 -0000 Received: from unknown (HELO mx.thebrainroom.net) (65.200.24.98) by pb1.pair.com with SMTP; 28 Jun 2004 09:08:09 -0000 Received: by mx.thebrainroom.net (Postfix, from userid 517) id 3952A14880D4; Sun, 27 Jun 2004 14:53:30 -0700 (PDT) Received: from BAUMBART (p508EB221.dip.t-dialin.net [80.142.178.33]) by mx.thebrainroom.net (Postfix) with ESMTP id 12D2714880D2; Sun, 27 Jun 2004 14:53:27 -0700 (PDT) Date: Sun, 27 Jun 2004 23:54:41 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <1143783909.20040627235441@marcus-boerger.de> To: Gareth Ardron Cc: internals@lists.php.net In-Reply-To: <20040624112730.GA14349@snipe.visualcode.co.uk> References: <20040624112730.GA14349@snipe.visualcode.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 8bit X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on jc.thebrainroom.net X-Spam-Status: No, hits=0.8 required=5.0 tests=PRIORITY_NO_NAME autolearn=no version=2.63 X-Spam-Level: X-TBR-Filter: Virus scanned and defanged Subject: Re: [PHP-DEV] __Destruct() functionality From: helly@php.net (Marcus Boerger) Hello Gareth, __destruct will get executed during request shutdown after the communication has been shutdown. The only way to be able to write from within __destruct is to deinitialize it at the end of the script and therefore before the request is being finished. To do so you can use 'unset($object);' regards marcus Thursday, June 24, 2004, 1:27:30 PM, you wrote: > ok, > If this is fixed in cvs, I appologise - google wasn't suggesting that > this has come up before. > I've just been playing around with the __destruct() function a little > bit, and seeing exactly what I could do with it. > Basically, I have a company info class, and a logger class. The logger > class is loaded and called by the main script first, with the object > accessed through $LOG. It's only very basic $log->event(""); type > functions though. Now, this $LOG is then passed to the company info > class when that is initialised (the way it's set up, I'm deliberatly > avoiding extending classes for this). > From this point, companyInfo class takes the $LOG variable passed to it > in the __construct() method and assigns it to a private variable within > the class. > What I'm then trying to do within the __destruct() method is to then do: > if ($this->LOG->events) { > $this->LOG->event("Leaving company info class"); > } > However, what seems to be happening is that this is not being executed, > presumably as the variables/objects have been removed from memory before > __destruct() is called. I'm also getting no warning whatsoever. > It'd seem to me, that the ability to call variables within __destruct() > is quite valuable, as you're kinda limited to just printing output > otherwise (ok, not strictly true, but you get what I mean). > This is with php5-rc3 btw. > Can anybody confirm that this is 'intended' behaviour - because it seems > bloody odd if it is. > Cheers. > -- > Gareth Ardron -- Best regards, Marcus mailto:helly@php.net