- Canada's Leading Web Hosting and Domain Name Provider

PHP 8.0 is Here! What’s new?

This November was an important month for users of cPanel: PHP 8 support was released on November 26th. The last time a major version was released was 2015, which was ages ago in Internet time. 

First things first: as a CanSpace customer, we want you to know support for PHP 8 is available immediately. Here are some important features and improvements to be aware of in the new PHP 8.

Just-in-Time (JIT) Compiler

One of the most anticipated features of PHP 8 is the JIT compiler, which pretty radically changes what is possible with PHP. 

There are three reasons for its introduction:

  • it allows for further optimization that would not be possible without it
  • it may open the door for PHP being more frequently used in other, non-Web, CPU-intensive scenarios 
  • it can eventually provide users with the ability to develop built-in functions in PHP, instead of (or in addition to) C, facilitating future innovation

The PHP team has said,

PHP JIT is implemented as an almost independent part of OPcache. It may be enabled/disabled at PHP compile time and at run-time. When enabled, native code of PHP files is stored in an additional region of the OPcache shared memory and op_array->opcodes[].handler(s) keep pointers to the entry points of JIT-ed code. This approach doesn’t require engine modification at all.

Constructor Property Promotion

It’s no secret that currently, PHP has a clunky way of dealing with objects. In all previous versions of PHP, the definition of simple value objects requires all properties to be repeated at least four times: in the property declaration, the constructor parameters, and twice in the property assignment. 

Borrowing some syntax from PHP sister language Hack, the constructor property promotion introduces a shorthand syntax, which allows combining the definition of properties and the constructor.

Support for Union Types

Before PHP 8, properties, parameters, and return types could only have one type. With PHP 8, users can now declare more than one type for arguments, return types, and class properties.

Reclassified Engine Warnings

In PHP 8.0, the development team revisited engine warnings, many of which were outdated relative to their actual seriousness, for historical reasons. For example, accessing an undefined variable, while being a very severe programming error, only generates a notice. Here is a table of the redefined error types and their new level of warnings.

Have more questions about PHP 8.0, and how it could affect your website? Reach out to us!

CanSpace Team

CanSpace Solutions is Canada's leading domain name registrar and web hosting provider. Keep an eye on our blog for expert information on domain names, websites, and running a business online.