PHP 7.4 Now Available

Sunday, December 8, 2019

PHP 7.4 Available AsrHost All Server

It’s that time again. Time for Santa to hitch up the ElePHPants that power his sleigh and deliver that present all good developers have been waiting for, the newest release of PHP. I took a quick peek in Santa’s bag and here are my top three features coming in PHP 7.4.

Arrow Functions

Anonymous functions in PHP are great. Many times though, they are overly verbose for what is needed. If all you need is a single expression you end up writing a lot of code to get that single expression. Now in PHP 7.4, single expression anonymous functions can be written in a single line.  The new syntax is clean, and the end result is much more readable code.

Null Coalesce short(er) syntax

One of my favorite additions to PHP 7 was the null coalexce operator. (??) SInce its inception I’ve used it in almost every body of code I’ve written to ensure that variables have a sane default. Now with PHP 7.4 developers can use an even shorter syntax. Keeping in line with the increment operator, we can now use “??=” to assign a default value to a variable if it is null, but leave it unchanged if it has a value.

Typed Properties

I love the new strong typing features in PHP 7. Each release have given us new options and made strong typing PHP code easier and stronger. All the while, the core developers have been sensitive to those who do not want to implement strong typing making all features optional. PHP 7.4 continues this tradition by extending strong typing to class properties. Now type hinting is not limited to method properties and return types, developers can hint the properties in their class as well. 

 

Santa’s bag contains a lot more presents for good PHP developers around the world.  So make sure you are prepared. Get to bed early on release night. Don’t forget to leave a glass of milk and some cookies out for Santa, and don’t forget to set out a 100 pound bag of peanuts for his ElePHPants. 

How to enable PHP 7.4