Invoke¶
It is possible to invoke an object, that means calling a function built with the object as the function name.
Invocation is based on the __invoke magic method.
Being invokable means that an object may be used as a function name.
<?php
class x {
function __invoke($a) {
echo 'I am '.$a;
}
}
$x = new x;
$x('x'); // I am x
?>
See also The Magical invoke Method in PHP. Your Clean Code Ally.
Related : Magic Methods, __invoke() Method