PHP, or Hypertext Preprocessor, is the scripting language widely used to develop WordPress themes and plugins. Using the most recent version of PHP is the quickest way to improve the performance of your site. PHP 7.3, which was released in April, introduced improvements in security and performance. WP Engine customers who moved from PHP 7.2 to PHP 7.3 have seen up to a 15% decrease in request processing time. This mirrors official PHP benchmarks that show PHP 7.3 is 10% faster than PHP 7.2.
Unfortunately, the majority of WordPress users aren’t using the most recent version of PHP. In fact, more than half of WordPress users are using PHP version 7.0 or earlier. At WP Engine, we recognize that dampens the incentive for WordPress developers to utilize the latest version of PHP-doing so would alienate half the market. Additionally, earlier versions of PHP are often in the end-of-life stage without active support; software that isn’t actively maintained is risky to use. If the majority of WordPress was in the practice of updating PHP versions, it would benefit the CMS as a whole. That’s why WP Engine is committed to offering the latest version of PHP. Doing so allows our customers to take advantage of the best performance and security that WordPress has to offer.
The latest version of PHP, PHP 7.4, is tentatively scheduled to be released on November 28th, 2019. PHP 7.4, which is currently in feature-freeze beta, brings important improvements to performance as well as enhancements to code readability, comprehensibility, and maintainability. Keep reading for more information on what we at WP Engine have deemed most relevant to our customers in PHP 7.4:
Bringing More User-Friendly Code into PHP
The shift from PHP 7.2 to 7.3 was all about performance and syntax. PHP 7.4, on the other hand, aims to bring more improvements to the usability, readability, and maintainability of code; this will ultimately make PHP less redundant, faster, and more reliable. Here are some RFCs (Request for Comments) scheduled for release in 7.4 that should help improve the experience of working with PHP:
- Arrow Functions: Short functions, also called arrow functions, allow developers to write shorter functions in PHP. Short functions have only one expression, which is also the return statement. Because of this, arrow functions are most suitable for one-line closure statements. These functions help improve the volubility of code.
- Typed Class Declaration: Another feature that is being added to PHP 7.4 is typed class properties. Users can opt-in and this addition is non-breaking to older versions of PHP. Types classes will only work in classes and they need an access modifier.
- Null Coalescing Assignment Operator: The null coalescing assignment operator, a shorthand for null coalescing operations, helps eliminate code redundancy for certain operators.
- Support for Weak References: Weak References allow the programmer to retain a reference to an object which does not prevent the object from being destroyed. This empowers developers to create cache like structures. Direct support for weak refs will be introduced in 7.4.
Deprecations are a notice to developers that certain functionality will be removed in the future. These are important to note ahead of the November 28th release date.
Be sure to check the RFC page for a full list of deprecations.
The real incentive for upgrading your PHP version is the promise of a performance boost. PHP 7.4 will deliver on that. PHP 7.4 will introduce preloading to PHP core. This is essentially done via an extension to Opcache, the software that stores precompiled script bytecode in shared memory. This helps eliminate the need for loading scripts on every request.
Opcache works by using opcodes, simplified versions of your code. Preloading works by compiling source files to opcodes, compiling like things together, and keeping the compiled code in memory. This code will be much easier and faster for PHP to pull than the alternative: files loaded and linked on every request. This will result in huge performance gains and is the most compelling reason to update to 7.4.
PHP 7.4 promises to offer a few improvements and we expect to see a small performance boost. We predict that PHP 8.0, which is already on the horizon, will be a much larger update. PHP 7.4 is not yet available, but when it is, WP Engine will work to offer PHP 7.4 to our customers in a timely matter. So that you can be running the fastest, most secure experience possible, we’ve developed our PHP Selector and PHP Test Driver. No other tools allow you to preview your site on a new PHP version, and then make the switch with a click of a button. These tools are easy to use and free on every WP Engine plan type!
For more information on the experience of upgrading PHP versions with WP Engine, check out this customer testimonial. Check this out for more information on the current PHP version, PHP 7.3.