Archive

PHP 8 Now Available

We are very excited to announce that PHP 8 is now supported in Aqua Panel. With both some very big changes under the hood and numerous quality of life improvements, PHP 8 promises to result in some big changes in PHP code going forwards.

Please Note: Before we go into some of the new features of PHP, we should say right here that we do not currently recommend setting your site to using PHP 8. This is due to the large number of potentially breaking changes it introduces. We’d recommend making use of our staging feature for testing upgrades.

Here’s just a few of the changes PHP 8 brings to the table:

Just in Time (JIT) Compilation

JIT compilation is probably one of the biggest changes to PHP 8 in terms of the low level architecture, but also not as likely to create immediate speed improvements as some may think. JIT compilation essentially caches the low level machine code the PHP interpreter generates from your PHP code. This has the potential for big impacts in terms of performance. However because of how JIT works, code has to be specifically written in the right way to make use of it. Most web application code (WordPress included) won’t be written in that way, but we’re likely to see that change over the next few years.

Named Arguments

Named arguments allows you to pass values to a function via the value name rather than just in order. For example if you had:

function foo($a, $b, $c=null, $d=null){ /*...*\ }

You could now call it like so:

foo(a: 1, b: 2, d: 4);

New String Functions

PHP 8 adds some new functions to make finding data in strings a bit easier. str_contains() allows you to check if a string appears in another string. Meanwhile str_starts_with() and str_ends_with()allow you to find if a string appears at the start or end of another string respectively.

Non-capturing catches

You are now able to specify a catch without needing to store it in a variable first. So the following code is now valid:

try {
// Code
} catch(Exception) {
// More Code
}

 

You can find out more at PHP’s official launch page here

How to enable

The process for enabling PHP 8 on your site is the same as with previous versions. Simply log into Aqua Panel and select PHP Version from the Advanced Menu. You can then select from any PHP version between 7.2 and 8.0 in the dropdown box.

 

We look forward to hearing your feedback!