Call a static variable from instance

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
It's possible to call a static variable/method from an instance:


I need to do something like this

$obj = new Object(); // (I have dynamic Object type)


There's any workaround?

Thanks in advance,

Re: Call a static variable from instance

Quoted text here. Click to load it

Just write a getter/setter for it:

class Foo {
    public static $bar;

    public function getBar() {
        return self::$bar;

    public function setBar($val) {
        self::$bar = $val;

Site Timeline