Closure
Closures, also called lambda functions, are anonymous functions: functions without a name. They are also supported by the eponymous Closure class.
They are close to the arrow-functions. They are also created with the ... operator, also known as the first class callable.
<?php
$closure = function ($a) use ($b) {
return $a + $b + 1;
};
print get_class($closure); // Closure
$closure2 = strtolower(...);
print get_class($closure2); // Closure
$closure3 = fn($a, $b) => $a + $b;
print get_class($closure3); // Closure
?>
See Also
Related
- static
- Arrow Functions
- Anonymous Function
- First Class Callable
- Callables
- Callbacks
- Anonymous Class
- Closure Binding
- Functions
- Return
- Sort
- Use
- Callable Arrays
- Array Callback
- Bind
- Inherited Variable
- Closure Class
- Custom Function
- Lexical Variable
- Currying
- Homoiconicity
- Meta-object Protocol (MOP)
- Recursion
- $this
- array_filter()
- Function Subscripting
- Generator
- Partial Application
- yield from Keyword
- Yield