Arrow Functions¶
Arrow functions are a type of closure with a specific syntax. It only accepts one expression, and uses all the variables from the local context of definition. They may also be marked as static
, to prevent this last feature.
<?php
$b = 10;
$fn = fn($a) => $a + $b + 2;
?>
Related : static, Functions, Closure, Anonymous Function, First Class Callable
Added in PHP 7.4