Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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:mac_doggie@hotmail.com
the Netherlands...
Sign In or Register to comment.