PHP North West, a UK based conference that brings together developers from across the globe, has just celebrated its 10th anniversary. I’m a big fan of PHP so when I hear about a PHP event taking place I am always keen to attend.
Speaking at the conference was Rasmus Lerdorf, known now as the Father of PHP. Rasmus is the Canadian developer that initially created the language back in 1994. His opening keynote talk explained the advantages of upgrading to PHP 7.
PHP 7 is a massive upgrade in terms of performance and stability and Rasmus is keen to see developers make the switch. I will highlight some of the key points that were covered in this talk many of which I use myself to promote upgrading to PHP 7.
Why Is Upgrading To PHP 7 Necessary?
PHP 7, a long-awaited update, took over from the previous version, PHP 5.6. This version is no longer maintained aside from security patches, and even this support will cease to exist in the next year. Earlier versions lack security support entirely and should be upgraded as soon as possible.
Performance is also a key factor especially as it is now taken into account by the likes of Google in search rankings. An upgrade to PHP 7 will see enormous boosts in speed.
In a benchmark test, PHP 5.6 and PHP 7 were compared side-by-side running the same WordPress CMS, a very common application of PHP on the web.
PHP 5.6 has available memory required 93.9mb per second
PHP 7 Was more than 6 times faster at 15.3mb per second
PHP 5.6 runs 212 requests per second
PHP 7 runs 476 per second
Mobile performance is also a key factor in search rankings, and PHP 7 is far better suited to mobile devices with a lower impact on server load.
Aside from improvements in performance and stability, it is just a nicer experience to code with PHP 7 with the introduction of features like scalar type hints, return types, and combined comparison operator.
PHP 7.2: The Future Of PHP
The future of PHP is looking ever brighter. It’s fair to say there is a lot of bad code circulating the internet, and currently, servers process this code, taking up extra unnecessary time. the next version of PHP will see this come to an end with the Dead code elimination feature which will see redundant code eliminated from production. See example below.
Just because this upgrade is imminent does not mean you should not be upgrading as soon as possible from 5.6. An upgrade to PHP 7.2 will be far easier if you have upgraded to 7 already.
What To Know Before Upgrading
A lot has changed in PHP 7, and from my experience, when upgrading well-maintained code that meets modern standards the process has been smooth. Older projects may not be so smooth as there are some features that have inevitably come to the end of their life-cycle. Some of these features still show up in older projects ,and developers should expect to perform some maintenance before upgrading.
Frequently Found Outdated Features
- MySQL will no longer be supported at all in PHP 7 so a replacement like PDO or MySQLi will be essential.
- ASP style tags have been removed
- The functions call_user_method() or call_user_method_array() have been removed.
- All ereg functions have been removed