Get Ready for PHP 7 - OneHost Cloud
- September 6, 2019
- 0
- OneHost Staff
2015 has been an important year for PHP. Eleven years after its 5.0 release, a new major version is finally coming our way! PHP 7 is scheduled for release before the end of the year, bringing many new language features and an impressive performance boost.But how will this impact your current PHP codebase? What really changed? How safe is it to update? This post will answer these questions and give you a taste of what’s to come with PHP 7.
Performance Improvements
Performance is undoubtedly the biggest reason why you should upgrade your servers as soon as a stable version is released. The core refactoring introduced by the phpng RFC makes PHP 7 as fast as (or faster than) HHVM. The official benchmarks are impressive: most real world applications running on PHP 5.6 will run at least twice as fast on PHP 7.For detailed performance benchmarks, have a look at Rasmus Lerdorf’s presentation at PHP Australia. (You can use the arrow keys to navigate through the slides.) Here are some WordPress benchmarks from that:
PHP 7 handles more than twice as many requests per second, which in practical terms will represent a 100{de1057fcf39365da6bc8e0d7e1ff82afd9d2038b2a9cca06bc963838b941c688} improvement on performance for WordPress websites.
Backwards Compatibility Pitfalls
Let’s talk about the few things that could potentially break a legacy application running on older versions of PHP.
Deprecated Items Removed
A number of deprecated items have been removed. Because they’ve been deprecated for some time now, hopefully you aren’t using them! This might, however, have an impact on legacy applications.In particular, ASP-style tags ( <{de1057fcf39365da6bc8e0d7e1ff82afd9d2038b2a9cca06bc963838b941c688}, <{de1057fcf39365da6bc8e0d7e1ff82afd9d2038b2a9cca06bc963838b941c688}= and {de1057fcf39365da6bc8e0d7e1ff82afd9d2038b2a9cca06bc963838b941c688}> ), were removed along with script tags ( <script language=”php”> ). Make sure you are using the recommended <?php tag instead. Other functions that were previously deprecated, like split, have also been removed in PHP 7.The ereg extension (and all ereg_* functions) have been deprecated since PHP 5.3. It should be replaced with the PCRE extension (preg_* functions), which offers many more features. The mysql extension (and the mysql_* functions) have been deprecated since PHP 5.5. For a direct migration, you can use the mysqli extension and the mysqli_* functions instead.
Use of this Site is subject to express terms of use. By using this site, you signify that you agree to be bound by these