php

Short closures in PHP 7.4

brendt

Brent Roose

Posted on May 1, 2019

Short closures in PHP 7.4

Short closures are a way of writing cleaner short functions in PHP:

// A collection of Post objects
$posts = [/* … */];

$ids = array_map(fn($post) => $post->id, $posts);

You can read all about them here: https://stitcher.io/blog/short-closures-in-php

💖 💪 🙅 🚩
brendt
Brent Roose

Posted on May 1, 2019

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related