PHP is continuously evolving and PHP 8.0 is released on November 26th, 2020. It is a mega edition as it explores a lot of features and performance improvements and deprecations to the language. The most talked about feature is the JIT compiler. Performance improving features like JIT deserve the popularity, the syntactical improvements may have more of a true impact for PHP practitioners- in the short term.

Here, we’ll discuss some of the notable features and improvements in PHP 8, including the JIT compiler and syntactical improvements that developers will surely like.

What’s New Features And Improvements In PHP 8.0?

1. JIT (Just In Time) Compiler-
One of the most exciting additions to PHP 8 is JIT compiler. As we all know that, php is an interpreted language, means it runs in real time, instead of being compiled and run at launch. JIT brings compiled code to PHP, and with it, better performance in some situations. It you’re working with web applications as most PHP developers are, JIT will not help much as these performance benchmarks show. However with the tasks like 3D rendering, data analysis, artificial intelligence and other long-running processes, it makes a huge difference. These are not common applications of PHP, but many developers are branching out, so this makes the engine more flexible. JIT makes certain to open PHP’s horizons and bring in devs interested in trying new things. For already existing projects, it might not do more. Prior to implementing JIT, ensure that you’ve tested it in an isolated environment and see whether it improves your performance or not.

2. Attributes-
Now, PHP supports attributes, or small pieces of metadata you add to parts of your code: functions, classes, parameter etc. Which means you don’t need to use docsblocks as a workaround.

You can add various attributes to any part of the code, import them with use statements and add parameters to attributes also. Add attribute to your code with signs: <>.

<>
class Foo
{
<>
public const FOO = ‘foo’;

<>
public $x;

<>
public function foo(<> $bar) { }
}

$object = new <> class () { };

<>
function f1() { }

$f2 = <> function () { };
$f3 = <> fn () => 1;
Note that attributes are not backwards compatible and will cause errors if ported into older versions of PHP. The docblock workaround is functional, however it’s always been somewhat clunky. Now, you can add attributes directly. For such a small addition, it has huge implications.

3. Union Types-
Know more at- https://solaceinfotech.com/blog/whats-new-in-php-8-0/https://solaceinfotech.com/blog/whats-new-in-php-8-0/

#php #php8 #software #development #technology

What's New In PHP 8.0? - Solace Infotech Pvt Ltd
1.35 GEEK