PHP 8.0 – the latest edition of the popular scripting language – is here, just one year after PHP 7.4 was released in November 2019.
We’re happy to announce that we will be deploying the latest version of PHP 8.0 (currently 8.0.3) on our hosting and reseller hosting servers, alongside PHP 7.4, 7.3 and 7.2. Previously, PHP 8.0 (Release Candidate 1) was only available for staging environments to prevent incompatibility errors on production sites.
PHP 8 is expected to facilitate developers to write cleaner code with better quality that gets executed faster.
Before we cover the new hotness, keep in mind that PHP 7.4 will be actively supported until December 2021. However, keeping your website code up-to-date and switching to new versions of PHP has various advantages: new functions offer new possibilities, performance can be massively increased, and security gaps are closed. Consider upgrading now!
New Features in PHP 8
This new version is a major update with some key improvements. A few notable additions to PHP 8.0 are explained below.
- Just In Time (JIT) compiler: caches part of your code in runtime to improve performance. PHP is not compiled, but interpreted line by line. The JIT compiler (Just in Time) works by compiling parts of the code during runtime – and in doing so acts very much like a cached version of the code. In time, developers may be able to implement this for improved website speed to negate the need for third party content delivery network (CDN) services.
- Named arguments: allows the developer to forget default values and the value order when passing the values to a function. This is done by specifying the argument name.
- Union types: used in other languages such as C/C++, TypeScript or Haskell. This allows developers to properly assign different types of values to a variable. It optimizes calls for cleaner code and better readability during security scans.
- Type juggling: will be more strict for better data input validation, mitigating some common code injection attacks.
- Attributes v2: PHP Attributes v2 are structured data allowing developers to add metadata to classes, properties, methods, functions, parameters and constants declarations. These attributes are set prior to the declarations.
- WeakMaps: WeakRefs were already added in PHP 7.4. With PHP 8, however, WeakMaps have been included which are the extension of this function. WeakMaps and WeakRefs can be used to delete objects when only the cache references the entity classes of the objects. This leads to resource-saving handling of the objects.
- Match expressions: Match – being an “Expression” – allows to set the value in a variable or return its value without the need for a local variable to be assigned. It also allows to forget the break; statement of the switch expression.
- Class syntax extended to objects: retrieves the name of a given object’s class with ::class.
- Removal of deprecated functions: including
$php_errormsg. Prior to updating you should ensure that your code is fully compatible with PHP 8.
Popular Web Applications Supporting PHP 8
As PHP 8 is a major release, it comes with some potential changes that may break your website. Prior to updating you should ensure that your code doesn’t need to be fixed according to the different deprecated Features and backward incompatibilities.
Here’s the latest information on PHP 8 support from the most popular CMSs.
- WordPress supports PHP 8 as of version
5.6but it’s not completely stable. In addition, not all plugins and themes are compatible with PHP 8.0. If you notice a plugin or theme issue on your site, we recommend downgrading to PHP 7.4 and reaching out to the developer of the plugin or theme regarding the PHP 8.0 incompatibility. WordPress core issues may already be in the queue for resolution.
- Drupal supports PHP 8 as of version
- Joomla added some core updates for compatibility in version
- Magento is currently prioritizing support with the Magento PHP 8 Compatibility Community Project.
End of PHP 7.2 support
The arrival of PHP 8 also signals the end of support for PHP version 7.2, for which support ended on November 30, 2020. So this is the moment to verify which version of PHP your website uses.
If you are using PHP version 7.2 or earlier, we’d suggest it is time to schedule an update of your website.