Newer PHP is faster and more secure, but older code may not work on it. You can make the switch without downtime if you prepare it and test it first, away from your live website.
Procedure
- Back up your website: files via FTP and the database via export, see Importing and exporting a database in phpMyAdmin.
- Update your application: the core system, the theme and all plugins to the latest versions. For WordPress see Updates and backups. For add-ons that the author no longer develops, look for a replacement.
- Test a copy of your website on a subdomain. Create a subdomain (Creating a subdomain), upload a copy of the website and the database there, and set the new PHP version for it.
- Go through the key functions: the home page, forms, login, cart and checkout, the admin area.
- Switch the live website, preferably outside peak traffic, and check it again.
- Watch for errors for a few more days: PHP errors and debugging.
- If something does not work, go back to the previous version in the admin panel, see Choosing a PHP version.
What has changed in newer versions
| mysql_* functions | removed in PHP 7. They are replaced by the mysqli and PDO extensions. Old code needs to be rewritten. |
| create_function(), each() | removed in PHP 8.0. |
| Dynamic class properties | deprecated since PHP 8.2 and they trigger a “Deprecated” notice. The website works, but the code should be fixed. |
| utf8_encode(), utf8_decode() | deprecated since PHP 8.2. |
| Stricter type checks | since PHP 8.0, things that used to pass with just a warning end in a fatal error. |
Deprecated messages are not an error
The Deprecated notice means the code uses something that will disappear in a future version. The website keeps working. However, you do not want to show these notices to visitors on a public website. Turn off the display of errors and save the messages to a log (see PHP errors and debugging).
If you have no developer
If your website runs on an old system that nobody maintains, consider modernizing it. Older PHP versions are no longer available, and they also carry a security risk. We are happy to advise you, write to us.