Santa’s Got a Bag Full of PHP 7.4 Goodies

PHP 7.4 is already available on all SiteGround servers and we have invited our great friend Cal Evans, who is also one of the most admired people in the PHP community, to share which are the best things in the new PHP version. 

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 everybody 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 has 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. 

PHP 7.4 can be enabled through our PHP Manager or from the Environment Options tab in the SiteGround Optimizer! Make sure you check your website thoroughly after switching to the latest PHP version since some plugins may not be ready for it yet. 

Access email sent!

Sign Up For
More Awesome Content!

Subscribe to receive our monthly newsletters with the latest helpful content and offers from SiteGround.

Thanks!

Please check your email to confirm your subscription.

Cal Evans

PHP Evangelist

One of the most admired people in the PHP community, who has dedicated more than 16 years to building the amazing PHP community and mentoring the next generation of developers. We are extremely honored that he is a very special friend of SiteGround too.

Comments ( 8 )

author avatar

Zoran Filipovic

Nov 29, 2019

Excellent job!

Reply
author avatar

Kathir

Dec 17, 2019

Great thanks for Latest PHP. I updated on my blog but unfortunately some plugin not compatible and my site broken. Hope soon all plugins compatible with 7.4.. Regards, Kathir

Reply
author avatar

Marina Yordanova Siteground Team

Dec 18, 2019

Hello Kathir, in that case, it's best to go back to the previous version that worked with your site plugins. It’s highly recommended to test new PHP versions on staging copies of your site first in order to prevent such issues on your production site.

Reply
author avatar

JetGuru

Jan 04, 2020

Thank you, SiteGround. Thank you for always offering PHP's latest, stable version. We have installed it and, so far, no issues, except the zip module is either not installed or not working. Most likely, it's not installed (confirmed at our end). Can you share more about this and any other modules not yet installed? Also, at what point is SG going to move from the managed version of PHP (7.1) to a higher revision level? It appears SG is falling behind on this. Again, thank you!

Reply
author avatar

Hristo Pandjarov Siteground Team

Jan 06, 2020

Well, I wouldn't say we're falling behind, we just deliberatelly didn't update the managed version right away. It takes little to no effort from our end to switch it but there were too many plugins that had issues with it. Actually, we plan to update it later this month so keep a close eye to the blog for news :)

Reply
author avatar

Heveloon ltd

Jan 14, 2020

Well done! We have a lots of applications written in php

Reply
author avatar

Serissa R. McAnally

Jan 22, 2020

Hello! Does anyone know if the new version of PHP has been tested with the OceanWP WordPress theme??? I'm scared to make the change and have my website go down. If this happens, can you roll back to the previous PHP version??

Reply
author avatar

Hristo Pandjarov Siteground Team

Jan 23, 2020

Works fine on several of my personal sites :)

Reply

Start discussion