Static Getters - Programmers Heaven

Howdy, Stranger!

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


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

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

echo ENV::$webroot;

will result in:
Fatal error: Cannot access private property ENV::$webroot in ...

this is how it is basicly setup:
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;

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...
mailto:[email protected]
the Netherlands...
Sign In or Register to comment.