0

I have been unable to think of or find a clean way to set a class static variables in php without setting them in each function. Is there anyway to have a setup like below.

class Foo{

    private static $bar;

    function __constructor(){
        self::$bar = new Object();
    }

    public static function test(){
        return self::$bar->call();
    }
}

Essential how can i set $bar to new Object() before every static call without setting it in test().

eatingthenight
  • 3,520
  • 3
  • 26
  • 38

0 Answers0