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.
Comments ( 8 )
Thanks! Your comment will be held for moderation and will be shortly published, if it is related to this blog article. Comments for support inquiries or issues will not be published, if you have such please report it through
Zoran Filipovic
Excellent job!
Kathir
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
Marina Yordanova Siteground Team
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.
JetGuru
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!
Hristo Pandjarov Siteground Team
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 :)
Heveloon ltd
Well done! We have a lots of applications written in php
Serissa R. McAnally
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??
Hristo Pandjarov Siteground Team
Works fine on several of my personal sites :)
Start discussion
Thanks! Your comment will be held for moderation and will be shortly published, if it is related to this blog article. Comments for support inquiries or issues will not be published, if you have such please report it through