Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:29801 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38073 invoked by uid 1010); 26 May 2007 11:49:46 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 38058 invoked from network); 26 May 2007 11:49:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 May 2007 11:49:46 -0000 X-Host-Fingerprint: 194.109.253.196 mediawave.xs4all.nl Received: from [194.109.253.196] ([194.109.253.196:5871] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2C/70-31507-8DE18564 for ; Sat, 26 May 2007 07:49:45 -0400 Message-ID: <2C.70.31507.8DE18564@pb1.pair.com> To: internals@lists.php.net Date: Sat, 26 May 2007 13:50:04 +0200 User-Agent: Thunderbird 2.0.0.0 (Windows/20070326) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 194.109.253.196 Subject: $var::$static From: bart@mediawave.nl (Bart de Boer) Hi all, I'd like to be able to do the following: ...in other words: I'd like to be able to access static class variables from inside an instance of the Base and/or Child classes. I'd also like to be able to access them dynamically. ($className::$variable) The only way to do this at the moment (to my knowledge at least) is to create functions in the Child class that returns its static variables. The downside of this is that those functions most likely will be very common (in my case they are) and should therefore belong in the base class. Hence: $this::$variable At the moment there is no way to access static variables from outside of the class dynamically. As a workaround for this I'm currently creating a temporary instance (new $type()) to access them dynamically with a __get() function in all the derived child classes. There are ways to do it with class constants and the constant functions. But it's not very elegant and class constants can't hold arrays and/or objects. I have no idea what the implications would be. Just thought it would be a nice addition to the language. :) Hope I didn't overlook some existing PHP feature that already allows me to do this. :| Cheers, Bart de Boer