When I call my static method by static::some_method(); it gives me the following error:
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting T_VARIABLE in /some/path/SomeClass.class.php on line 15
If I replace static with the class name it works of course, but what is the correct way to call a static method without using the classname?
If you are within the context of the class then
…will both work, with different behaviors related to
late static binding.If you are not in the context of a class, then you need to use the classname the method belongs to:
Otherwise you’ll get that goofy hebrew error,
T_PAAMAYIM_NEKUDOTAYIM, which means “double colon” in English.