PHP 7.4, the next PHP 7 minor release before PHP 8.0, has been released for General Availability as of November 28th, 2019.
PHP 7.4 is available to all ChemiCloud clients
Let’s dive into some of the most exciting improvements and new features that will make PHP faster and more reliable.
Table of Contents
PHP 7.4 New Features and Deprecations
You’ll find below a full list of new features, updates, and deprecations of several changes and features that should be added to the language with the final release of PHP 7.4.
New Features
- Typed Properties 2.0 – class properties now support type declarations.
- Arrow Functions 2.0 (Short Closures)- Arrow functions provide a shorthand syntax for defining functions with implicit by-value scope binding.
- Limited Return Type Covariance and Argument Type Contravariance
- Unpacking Inside Arrays
- Numeric Literal Separator – Numeric literals can contain underscores between digits.
- Weak References – Weak references allow the programmer to retain a reference to an object that does not prevent the object from being destroyed.
- Allow Exceptions from __toString() – Throwing exceptions from __toString() is now permitted. Previously this resulted in a fatal error. Existing recoverable fatal errors in string conversions have been converted to Error exceptions.
- Opcache Preloading – Preloading is the process of loading libraries and frameworks into the OPCache at module initialization.
Deprecations
The following functions/functionalities are deprecated with PHP 7.4:
- The real type
- Magic quotes legacy
- array_key_exists() with objects
- FILTER_SANITIZE_MAGIC_QUOTES filter
- Reflection export() methods
- mb_strrpos() with encoding as 3rd argument
- implode() parameter order mix
- Unbinding $this from non-static closures
- hebrevc() function
- convert_cyr_string() function
- money_format() function
- ezmlm_hash() function
- restore_include_path() function
- allow_url_include ini directive
For a more comprehensive list of deprecations, check out PHP 7.4 Upgrade Notes.
PHP 7.4 Performance Benchmarks
Phoronix ran some benchmark tests with PHP 7.4 Alpha and conclude that it is slightly faster than PHP 7.3.
The improvements in terms of performance might not be as significant as the update version from 5.6 to 7.0, but they are still present.
How to Switch PHP Version to PHP 7.4
PHP 7.4 is available for all ChemiCloud customers. Before doing the switch to PHP 7.4 we strongly recommend you to check the compatibility of your website’s code with the new PHP version. Some web apps, themes or plugins may not be fully compatible with it yet.
It is important to know that the following PHP extensions are not yet read for PHP 7.4:
- interbase
- ioncube_loader
- mcrypt
- oauth
- phalcon3
- recode
- sourceguardian
- wddx
If your web app or script is currently using the aforementioned PHP extensions, a change to PHP 7.4 is not recommended.
You can easily update your PHP version to 7.4, from cPanel, using the PHP Selector by following the steps described below:
1) Log in to your cPanel account.
2) Navigate to the Software section and click on Select PHP Version
3) Click on the PHP Version drop-down box and select 7.4 PHP version
4) Click on Set as current button to save your PHP version change
That’s it. PHP 7.4 has now been set as the default PHP version for your hosting account.
In case you see any error on your website once you’ve changed the PHP version, please revert back to the previous PHP version which your site was using.
We only covered some of the new features, updates, and deprecations of PHP 7.4. Visit the official source if you want to see a full list of all changes.
Conclusion
In this post, we covered some of the new features that we can expect with the release of the PHP 7.4 version. If you’re looking for the full list of features, updates, and deprecations along with the official documentation, check out the following resources:
If you’re a ChemiCloud client, you can already update to the latest PHP version.