News & Events

HOME

>

Our BLOGS

Recent News and Blogs

To help companies screen all the bidding contracts, we’ve turned to the latest digital software and operation tracking systems that filter 

WordPress Resources at SiteGround

We’re happy to announce that we have deployed the latest release candidate version of PHP 8 on all our servers. As always we are among the first companies to provide the new PHP on their hosting platform. PHP 8 is expected to facilitate developers to write cleaner code with better quality that gets executed faster. Since release candidates are not suitable for live sites, we invite you to try it out on a staging copy of your site or on projects that are not live yet. We’ll give away awesome PHP elephants to 10 of the early adopters who share their opinion about PHP 8 with us.

What Are The PHP 8 Improvements And Features
Faster Code Execution
The latest PHP version brings a lot of new things but the one we are obsessed with is JIT (just in time compiler). It is the first time that PHP version has a compiler – JIT – that caches a version of your already interpreted code and generates a machine code as an output (machine code is on with 0’s and 1’s only). The “just in time” compiler promises speed improvements for complex tasks and algorithms and opens new opportunities for the PHP language to broaden its reach and applications.

Some of you may wonder how JIT relates to the Opcache, which brought significant performance gains to many websites? The main job of the Opcache is to cut the processes of tokenization, parsing, and compiling of Opcodes, which then get processed by the Zend engine. The role of JIT is to save on the execution of the Opcodes by the Zend engine, so it joins forces and intervenes to spare resources where the Opcache cannot help.

It’s worth mentioning a few downsides we have noticed so far:

Running PHP 8 with JIT might make it harder for you to troubleshoot code errors because it may be harder to locate which piece of your code in this interpreted version is actually at fault.
If you are running a WordPress site you may not be able to note significant performance improvements thanks to JIT. The WP developers are still working on making WP compatible with PHP 8 and are now calling for testers, meaning you won’t be really able to test PHP8 on your WP site right away. Also, because of the way WP interacts with MySQL, a lot of the waiting time does not come from the PHP compilation, but from the MySQL response time, which cannot be solved with the help of the JIT compiler.
Code With Higher Quality
One of the major differences that you will notice is that many of the warnings and notices that weren’t catchable are now exceptions or errors, which can be caught and logged. It is possible that due to this change, a lot of problems that remained hidden with the previous PHP versions will now surface. This is a great improvement, as it will allow developers to spot potential issues easier. However, have in mind that it may be a good idea to set display_errors=Off if you decide to use PHP 8 on a live site to not show such errors to your site visitors.

Cleaner, Shorter Code
Some of the new elements, such as the nullsafe operator, greatly improve the readability of the code, making it shorter and neater. Instead of nesting several “if’s” you can use the “null” operator to write all those in just 1 line of code.

The “Type” Trend
For several versions now, PHP has been trying to define the arguments that each method could adopt and become more of a typed language. In this latest release, there is a feature called “union types” which allows you to define 2 value types for each function, which is a natural continuation of that trend. As the example below shows, the function can return an integer or a float:

public function getNumber(): int|float {
return $this->number;
}

The list of new features keeps going and we suggest this article as a good reference point for PHP developers:

https://stitcher.io/blog/new-in-php-8
https://stitcher.io/blog/php-jit
https://wiki.php.net/rfc/nullsafe_operator

Read More

© 2020 Nubron – All Rights Reserved