PHP 8.0 version was officially released on 26 November 2020. Now, it is available on all rate schedules of the virtual hosting. This version includes new interesting features, improvement of the performance and correction of errors.
What’s new
JIT
JIT (just in time) is a compiler that is available as an OpCache extension with PHP 8.0. The main advantage of JIT is productivity boosting by execution of a part of the code at the processor level while bypassing the execution on Zend VM.
Union Types
Support of the union types defining the collections of two types or more.
Nullsafe operator
Feature enabling to use ? operator to bypass individual conditional checks of the object for the null value.
Support of the named arguments of the functions
The values attached to the names of the parameters can be now transferred to the function. This enables to indicate parameters randomly and determine the optional arguments.
Compliance expression
Support of match expressions that, unlike switch, can return value, do not require break indication, support the combination of conditions and uses a rigorous comparison of types.
The syntax for a combination of properties of class and design view
The short syntax for defining classes enabling to combine the determination of design view and properties is now available.
New return type: static
In addition to the possible returnable parent and self types, static can be now returned.
New type: mixed
The mixed type will enable the developers to publish the information on the type for most features and properties of the class.
Throw expressions
Throw operator is converted into expressions, the use functionality is expanded.
::class on the objects
Now, ::class may be used on the objects (similar to get_class feature).
Unnamed exceptions
Now, there is the feature enabling to determine the exceptions in the catch block without attachment to the variable value.
Improved comparison of lines and numbers
Now, there are new features and options for work with lines and numbers. The behavior in comparison of line and number types is changed.
The prohibition on JSON disabling is added.
JSON is extremely useful and widely used, so now it is obligatory and cannot be disabled.
Correction of critical errors
- The standards for various types of errors are set
- The warnings are reclassified
- The @ operator does not “mute” the fatal errors anymore
- The level of error messages by default is changed
- The concatenation priority is changed
- Mute PDO error mode by default
- A more rigorous check of types for the arithmetic and bitwise operators
- Signatures of the Reflection class methods are changed
- A stable algorithm of sorting without loss of similar values sequence order is implemented
You can find the full list of changes in PHP 8.0 version on official website.
Attention
PHP 8.0 is a significant upgrade. So, please take a look at the changes before updating your hosting. Some changes of the new version can be unavailable for the outdated releases, and the work of the website can be incorrect after the PHP version is upgraded.
How to install PHP 8.0 in the virtual hosting panel
To do this, go to the ISP panel of your server and change PHP 8.0 version in the domain settings. The version switching is simple.
In the hosting management panel, go to the WWW section, then go to the WWW-domains subsection, select the domain from the list and press the Change button. In the window that popped up, select PHP 8.0.8 (alt) from the list in the PHP version line.