I know you can call static methods using variable as class name like so:
$className = "Foo";
$className::Bar(); //works
But when i'm trying to use static property as variable like this:
self::$className = "Foo";
self::$className::Bar(); //doesn't
it gives me the following parse error on line where i'm trying to call the method:
Parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM)
So how can i call that method using static property and is that even possible with syntax somewhat similar to what i described(w/o call_user_func and creating local variable that stores self::$className)?
selfrefers to the class name of the current class scope. So basically, what you are trying to say is "call a method (Bar()) from class ($className) of the current classself". It doesn't make much sense, does it?selfhas property$classNameand i'm trying to call a method from class which name is equal to$classNamevalue.