Re: Using Static Class Variables to Access Globally
| From: | Colin Guthrie | Date: | Wed, 24 Sep 2008 08:23:41 +0000 |
| Subject: | Re: Using Static Class Variables to Access Globally | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-280820@lists.php.net to get a copy of this message | ||
Nathan Nobbe wrote:
in many cases, people like to drive client code through methods, which, given the current set of language features in php, could be reason to favor a singleton w/ __get() & __set() methods defined. you still have the same 'global' scope, except that the data doesnt have to be public. (im not saying its bad to use public vars, im merely presenting an alternative perspective)./me prefers singleton with __get and __set but each to their own :) I quite like the fact that the __construct of the singleton itself can fill up the variables that are accessed via __get and from then on rogue code cannot overwrite them (assuming you do not implement a __set!) Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mandriva Linux Contributor [http://www.mandriva.com/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/]