I\'ve been wondering whether is possible or not to pass a function as parameter in PHP; I want something like when you\'re programming in JS:
object.exampleM
According to @zombat's answer, it's better to validate the Anonymous Functions first:
function exampleMethod($anonFunc) { //execute anonymous function if (is_callable($anonFunc)) { $anonFunc(); } }
Or validate argument type since PHP 5.4.0:
function exampleMethod(callable $anonFunc) {}