Is it OK to use PHP 8?

Instead of PHPDoc annotations for a combination of types, you can use native union type declarations that are validated at runtime.

Match expression RFC Doc

The new match is similar to switch and has the following features:

  • Match is an expression, meaning its result can be stored in a variable or returned.
  • Match branches only support single-line expressions and do not need a break; statement.
  • Match does strict comparisons.

Nullsafe operator RFC

$country =  null;

if ($session !== null) {
  $user = $session->user;

  if ($user !== null) {
    $address = $user->getAddress();

    if ($address !== null) {
      $country = $address->country;
    }
  }
}

$country = $session?->user?->getAddress()?->country;

Instead of null check conditions, you can now use a chain of calls with the new nullsafe operator. When the evaluation of one element in the chain fails, the execution of the entire chain aborts and the entire chain evaluates to null.

Saner string to number comparisons RFC

When comparing to a numeric string, PHP 8 uses a number comparison. Otherwise, it converts the number to a string and uses a string comparison.

Consistent type errors for internal functions RFC

Most of the internal functions now throw an Error exception if the validation of the parameters fails.

Just-In-Time compilation

PHP 8 introduces two JIT compilation engines. Tracing JIT, the most promising of the two, shows about 3 times better performance on synthetic benchmarks and 1.5–2 times improvement on some specific long-running applications. Typical application performance is on par with PHP 7.4.

You may have noticed that several hosting companies that offer web hosting have started advertising that you can use PHP 8 with them. But is PHP 8 something you should be aware of, and what impact could it have on your website?

There may be several good reasons to update your WordPress or Joomla site to use PHP 8.0. Among other things, it helps to increase the speed of your website. In this blog post, we dive into what else the new PHP update will mean for your website.

What is PHP?

PHP is an open source programming language consisting of “server-side scripting”, which is widely used for web development. PHP is an important language for the WordPress community because much of the core WordPress software is written in it.

According to W3 Techs, PHP is used by 77.5% of all websites worldwide. Even if you’re not a programmer, if you have your own website, you’re probably using PHP. If your website is made in WordPress or Joomla, these are two systems that use PHP.

What is the difference between PHP 7 and PHP 8?

At first glance, the difference between PHP 7 and PHP 8 is not very big. Certainly not if you are not a programmer and are familiar with the many features that have been added.

The function and task of PHP itself is the same in PHP 8.0 as it has been in the previous PHP versions. Where you as a regular user will primarily notice a difference will be the speed of your site. Among other things, the new PHP version 8 comes with a number of optimizations to the way your site handles requests.

FACTS – What does request mean?

When you visit a website, your PC or mobile executes a request to the website’s web server. A request is the communication between your browser and a web server that provides the user with the requested page and its content.

When a web server receives a request from a client (such as a PC or mobile), it will retrieve the requested material and display it on the user’s screen. Each time a request is made from the client, the server executes each request, resulting in the requested page, images or interactive features being loaded.

Will my website be faster if I update to PHP 8?

The loading time of a WordPress website is one of the things that PHP 8.0 noticeably improves and optimizes. The amount of requests that PHP 8 can handle is higher than in the previous versions. The faster your site can handle a request, the faster your visitors will be able to load your site.

On a new WordPress installation with PHP 7.4, the site can handle 110.24 req/sec. In comparison, PHP 8.1 can handle 163.43 req/sec. This means that PHP 8.1 is about 50% faster.

Do I need to update to PHP 8?

At Simply.com, we recommend that you use the PHP version that our engineers have enabled by default on the web server. Our technicians continually assess which PHP version is most stable with various CMS systems such as WordPress.

Simply.com has no plans to remove or stop offering PHP 7.4, just as we still offer various other PHP 7 versions (and even PHP 5.6).

Simply.com article “About PHP 7.4 end-of-life”

Simply.com has no plans to remove or stop offering PHP 7.4, just as we still offer various other PHP 7 versions (and even PHP 5.6).

Simply.com article “About PHP 7.4 end-of-life”

If you want to use an older version of PHP, you can manually customize the PHP version on your web hosting. On our support page, you can read our guide to changing the PHP version.

How do I manually update WordPress to PHP 8?

Just like any other electronics and IT that you use on a daily basis, PHP also needs to be updated. By updating the PHP version, you increase the security of the website and get access to the latest features.

  1. Login to your Simply.com control panel
  2. Open the File Manager
  3. Open the website folder

    If you only have a webhost, open the public_html folder.
    If it is a domain alias you want to change the PHP version on, open the folder for your domain alias.

  4. Open the .htaccess file
  5. Insert PHP 8 into .htaccess

    If you want your web space to always use PHP 8
    AddType application/x-httpd-php80 .php
     
    If you want your webhost to always use the latest PHP version
    AddType application/x-httpd-php-latest .php

  6. Save the change

    And like that your WordPress site is now running PHP 8.0

FAQ – PHP 8

What is PHP?

PHP is a popular open source programming language that enables developers to create dynamic websites and web applications. PHP is used to develop some of the world’s most popular website systems – including WordPress and Joomla.

Should I use PHP version 8?

PHP 8 lets you write concise code and build more exemplary applications with exciting changes and improvements to the earlier RFCs. Considering the new improvements, it would be a crime not to upgrade your current PHP version to PHP 8.1 on your WordPress site.

Which is better PHP 7.4 or 8?

PHP 8.0 is the clear winner here. OctoberCMS handled 20.16% more requests per second on PHP 8.0 than on PHP 7.4.

Is PHP 8 better than 7?

PHP 8 is faster than PHP 7, the syntax requires less code, and typing is better supported. These three improvement categories provide a powerful major version release of PHP.

How long will PHP 8 be supported?

Release
Released
Active Support
8.1
1 year and 2 months ago (23 Nov 2021)
Ends in 9 months (25 Nov 2023)
8.0
2 years ago (24 Nov 2020)
Ended 2 months and 1 week ago (26 Nov 2022)
7.4
3 years ago (26 Nov 2019)
Ended 1 year and 2 months ago (28 Nov 2021)
7.3
4 years ago (04 Dec 2018)
Ended 2 years ago (06 Dec 2020)
PHP | endoflife.dateendoflife.date › phpnull