/** * Arrow functions */ $fn1 = fn($x) => $x + $y; $fn2 = function ($x) use ($y) { return $x + $y; }; /** * Function invoke */ $date = new DateTimeImmutable (); $date->format('Y-m-d'); DateTimeImmutable::createFromMutable(new \DateTime('now')); str_contains (\strtoupper(substr('abcdef', -2), 'f')); /** * Function declaration */ function testMe(string|int $name): int { if (empty($name)) { return 0; } elseif ($name === 1) { return (int) $name; } switch($name) { case '2': return 2; default: throw new \Exception('error'); } } /** * First-class Callable Syntax */ $fun = mb_strlen(); $fun(); /** * Named arguments */ setAlarm( label: 'foo', time:time() + array(5)[0] + Foo::HOUR, );