As an example, you can use a function is_callable()that takes a function name as an argument and checks whether it can be successfully called from this point in the code.
If I want to check if an object's method is callable, it seems like I have two options when referencing a static method:
Option 1:
is_callable(array("ObjectName", "MethodName"));
Option 2:
is_callable("ObjectName::MethodName");
(Instance methods can apparently only be checked using option 1, passing the instance of the object as the first value of the array, rather than a string containing the class name.)
Is it just a matter of preference, or syntactic sugar, or is there a solid difference between the two?
source
share