What brings PHP 8?

PHP (PHP: Hypertext Preprocessor) is a scripting language that developers using creating web pages since 1995. PHP was created by Rasmus Lerdorf.

Through the years, new features were added. After major version 7 which bring to us a new Zend Engine (thing that power up PHP server) from 2016, a new version has arrived, PHP 8.

So what do we get?


In computing, just-in-time or JIT is a way of executing computer code that involves compilation during execution of a program, rather than before execution. The main benefit is execution speed, although not as big as we get in PHP 7.
As PHP 8 is still in beta, JIT is not enabled by default. You can easily enable it by adding “opcache. jit_buffer_size=100M” in php.ini.Here is the benchmark we did to test speed improvements. We create a simple PHP application in plain PHP and tested it on three major versions. You can see the results on top of this document.

Named Arguments

With named arguments, you can now pass an argument to a function based on the parameter name. This means that the order in which arguments are passed won’t matter, as the name will be used to determine the parameter.
Let me show you an example:

exampleFunction(name: baz, foo: bar);
exampleFunction(foo: bar, name: baz);

Now it is enough to remember only which parameters passing into the function, not order. How convenient!

Match Expressions

Have you ever wondered is it possible to make Switch statement more
pleasant to write? Now we have Match Expression for that.
This is example for switch statement:

$fruit = ‘banana’;
switch ($fruit) {
    case ‘orange’:
        $eat = ‘Tasty!’;
   case ‘banana’:
       $eat = ‘Nice!’;
   case ‘apple’:
       $eat = ‘Mmmmm!’;
   case ‘avocado’:
       $eat = ‘Yuch!’;

And this is for match expression:

$fruit = ‘banana’;
$eat = match ($fruit) {
     ‘orange’ => ‘Tasty!’,
     ‘banana’ => ‘Nice!’,
      ‘apple’ => ‘Mmmmm!’,
      ‘avocado’ => ‘Yuch!‘,

DRY to the bone!

Trailing commas at the end in parameter list are now allowed

Well, this is pretty much self-explanatory, you can now also leave the trailing comma off at the end of parameter lists and pop compilers want you bugging about that.
One thing to mention, this change only affects call syntax, not function declaration!

function hello(
)   {
     return $greeting .‘, ‘. $name .‘!’;
echo hello(‘Lilly’, ‘Hi’,);


PHP is a leading web development platform. More than 80% servers on the internet is running under PHP!
We can’t wait to see what features come next!