PHP 7 overview

 

Overview

It's highly recommended that you upgrade your PHP websites in the panel to use at least PHP 7.4 as this version offers significant improvements over older PHP versions.

This article explains many of the benefits as well as possible compatibility issues when upgrading such as the removal of several deprecated functions from previous versions. Because of this, users should not upgrade their sites until they are sure everything is fully compatible with the new version.

View the following article for instructions on how to update the PHP version of your site:

PHP 8 is the current major update to the PHP programming language which offers several benefits over previous versions, however, it may not be compatible with older PHP code. For this reason, you should confirm your code is first compatible with PHP 8 before upgrading.

Benefits

The following list is taken from php.net:

  • Improved performance: PHP 7 is up to twice as fast as PHP 5.6
  • Significantly reduced memory usage
  • Abstract Syntax Tree
  • Consistent 64-bit support
  • Improved Exception hierarchy
  • Many fatal errors converted to Exceptions
  • Secure random number generator
  • Removed old and unsupported SAPIs and extensions
  • The null coalescing operator (??)
  • Return and Scalar Type Declarations
  • Anonymous Classes
  • Zero cost asserts

General upgrading guidelines

  • You can update the PHP version of your site in your panel.
  • Make sure your software and any plugins/themes/extensions are compatible with PHP 7 before you upgrade.
  • Make sure your database queries are using mysqli or PDO_MySQL to connect as the mysql extension has been removed. View the My site will not connect to my database after upgrading to PHP 7 section below for details.

PHP 7.3 Known issues

JIT compilation failed: no more memory errors

If you are seeing "JIT compilation failed: no more memory" errors on your site, this is due to a known bug in PHP 7.3. To work around this, you can disable the JIT compiler by adding the following line to your phprc file:

pcre.jit = 0

If you need assistance creating and/or modifying this file, then refer to the following instructions:

Alternatively, you may upgrade to PHP 7.4 in your DreamHost panel to avoid this error.

mcrypt.so

Support for mcrypt has been removed starting with PHP 7.2.0. Any scripts that depend on mcrypt will need to be updated to use OpenSSL or Sodium instead.

FAQs

What happened to PHP 6?

This was a development version that never became an official release. View the following links for further information:

Troubleshooting

My site will not connect to my database after upgrading to PHP 7

Previous versions of PHP offered three PHP APIs for accessing a MySQL database. They were:

PHP 7 has removed support for the mysql extension and affects the following:

  • Any queries using a mysql_connect function will not function.
  • PHP 7 only allows connections to a MySQL database using mysqli or PDO_MySQL.

All scripts must be updated in order to continue functioning.

Session errors

The following PHP error may appear if your code uses sessions.

[Tue Jan 05 12:41:24.497212 2021] [fcgid:warn] [pid 16093:tid 4253425600256] [client xxx.xxx.xxx.xxx:11929] mod_fcgid: stderr: PHP Warning: session_start(): Failed to read session data: user (path: /home/username/tmp/) in /home/username/example.com/file.php on line 212

View the following solution from PHP.net for details on how to resolve this warning.

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?