PHP Tutorial: What's New in PHP 7.4

Version 7.4 of PHP was released a little less than a month ago and I suggest you take a look at the new features brought by this version.

Short arrow function

A new syntax has been added to write a short function that has only one instruction. This syntax will simplify simple callback writing.

// PHP 7.3
$ items = array_filter ($ items, function ($ i) {return $ i% 2 === 0});

// PHP 7.4
$ items = array_filter ($ items, fn ($ i) => $ i% 2 === 0);

It is also interesting to note that these functions do not require the use of the use () for the use of external variables: ...

Read more


Please enter your comment!
Please enter your name here