Functions
PHP Manual

Anonymous functions

Anonymous functions allow creation of functions without specifying their name. They are most useful in callback parameters but the usage is not limited to that.

Example #1 Anonymous function example

<?php
echo preg_replace_callback('~-([a-z])~', function ($match) {
    return 
strtoupper($match[1]);
}, 
'hello-world');
// outputs helloWorld
?>

Anonymous functions are internally implemented by the Closure class.

Note: Anonymous functions are available since PHP 5.3.0.


Functions
PHP Manual