How can I call an object's method if I know the method name at runtime?
If you have an object and try to use an expression to provide the method name with the "." operator like this:
$obj.$name($argument)
It will fail - this does not work because the parser thinks that the expression before the first open parenthesis "(" is a call reference.
In order to call an object method with an expression giving the method name, use the callObjectMethod() or callObjectMethodArgs() function like this:
callObjectMethod($obj, $name, $argument);
Also the list of accessible methods can be retrieved by calling getMethodList() on the object.
| < Prev |
|---|





