In PHP it is possible to assign an anonymous function (closure) into a PHP variable. The syntax of this assignment is same as any other assignment. The closure is then called with a parenthesis and parameters (optional) after the variable.
Example
$writeMsg = function ($param) { echo $param; }; $writeMsg('PHP closure');
Output
PHP closure
Comments
Post a Comment