Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

PHP 7.4: New Features, Removed Parts and Speed

This guide gives a simple tour of PHP 7.4. You will learn what is new, what is going away and why it is faster.

Domains and DNS2 min read5 steps2 screenshots

What is PHP?

PHP is a language that runs many websites, including WordPress. A version number tells you how new it is. PHP 7.4 came out in November 2019.

Tip: PHP 7.4 is old and no longer gets security fixes. Newer versions work in a similar way and are safer. Use a newer one if your site allows it.

New features

  • Typed properties. You can say what kind of value a variable must hold. A variable is a labelled box that stores a value. This catches mistakes early.
    public int $age;
    This says the box must hold a whole number.
  • Arrow functions. They are a short way to write a small function.
    $double = fn($x) => $x * 2;
    This makes a tiny function that doubles a number.
  • Null coalescing assignment. A short way to set a value only if it is empty.
    $name ??= 'Guest';
    This sets the name to Guest if it has no value.
  • Spread operator in arrays. You can merge lists with three dots.
  • Preloading. The server can load code into memory once to save time.

Deprecations

Deprecated means "still works, but will be removed later". PHP 7.4 warned about a few things.

  • Using curly braces to read parts of a text, like $str{0}.
  • The real type and the is_real() function.
  • Some old ways to join text and arrays with implode().
  • Nested ternary operators without brackets.

Warnings show in your error log. Fix them before you upgrade to a newer PHP.

Speed

PHP 7 versions are much faster than PHP 5. Version 7.4 adds small gains. Preloading and better memory use help most. Your site may load a little quicker and use less memory.

How to switch the PHP version

  1. Back up your website first.
  2. Log in to cPanel.
  3. Find Select PHP Version or MultiPHP Manager.
    Screenshot: Find Select PHP Version or MultiPHP Manager .
  4. Choose your domain and pick the version.
  5. Save and test your site.

If the option is missing, open a support ticket.

Warning: Old plugins or themes may break on a different version. Test first, and keep your backup.

Quick recap

  • PHP 7.4 added typed properties and arrow functions.
    Screenshot: PHP 7.4 added typed properties and arrow functions.
  • Deprecated means it will be removed later.
  • It is faster than PHP 5 but is now old.
  • Back up and test before changing the version.