Thursday, April 4, 2013

PHP Functions - Closures - Anonymous

Anonymous functions = closures,

These allow the creation of functions which have no name. They are most useful as the value of callback parameters.  

$funcName = function($name)
{
    printf("Hello %s\r\n", $name);
};

$funcName('Anonymous function');
$funcName('Closure');

No comments:

Post a Comment