While I understand that static methods can be invoked through a variety of approaches, such as:
A::staticFunction();
OR
$class = 'A';
$class::staticFunction();
OR
$a = new A(); // Assume class has been defined elsewhere
$a->staticFunction();
However, could someone please explain why the following won't work, and if possible, how to make this work (without resorting to the solution provided):
// Assume object $b has been defined & instantiated elsewhere
$b->funcName::staticFunction(); // Where funcName contains the string 'A'
This produces the following PHP parse error:
Parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM)
Typical working solution (follows second approach) (preferably avoid if possible):
// Assume object $b has been defined & instantiated elsewhere
$funcName = $b->funcName; // Where funcName contains the string 'A'
$funcName::staticFunction();