Static Getters - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Static Getters

mac_doggiemac_doggie Posts: 488Member
Hi,

I have a class that has some static properties. I don't instantiate this class, but only use the statics...

Since I made those properties private I'd like to be able to use my __Get method to acces the value I have stored in it... But the problem is

[code]
echo ENV::$webroot;
[/code]

will result in:
[code]
Fatal error: Cannot access private property ENV::$webroot in ...
[/code]

this is how it is basicly setup:
[code]
class ENV {
private static $webroot;

public static function Initialize() {
self::$webroot = 'some value I get from my inifile';
}

public static function __Get($value) {
return self::$$value;
}
}
[/code]

I fugured I needed a double $ sign in the getter because $value returns the name of the private static property, so else it would compile to: return self::webroot (without any $) I experimented a bit with this, but nothing sems to be working. Has anyone got any idea?

thanks in advanced...
;-)
-mac-
mailto:[email protected]
the Netherlands...
Sign In or Register to comment.