Also called: closure, fn, callable, anonymous function
Example
The function slug("Hello Bali") returns "hello-bali".
In code
function slug(string $text): string {
return strtolower(trim(preg_replace('/[^a-z0-9]+/i', '-', $text), '-'));
}
$double = fn (int $x) => $x * 2;
Related terms
Added 2026-11-30 · Last reviewed 2026-11-30