Anonymous Function

A function may be instantiated, without defining a function name. Such functions are called anonymous.

Anonymous functions are defined as closures or arrow functions. They may also be created based on existing methods and functions, with the ... operator.

Even without names, they are usable like functions, or as callable.

Methods cannot be anonymous, but it is possible to call a method without mentioning its name by using the __invoke magic method.

<?php

    $closure = function () {} ;

    $arrowFunction = fn() => 1;

    $fcs = strlen(...);

?>

Documentation

See also Anonymous functions in PHP.

Related : Closure, Arrow Functions, First Class Callable, Closure, Anonymous, Arrow Functions, __invoke() Method, Custom Function, Functions, Lexical Variable