Skip to content

Emergency patch, £245 fixed →

Upgrading PHP 7.4 to PHP 8.5: Everything That Breaks, and How to Fix It

A version-by-version guide to moving from PHP 7.4 to PHP 8.5: the comparison and TypeError changes in 8.0, the null deprecations in 8.1, what 8.2 to 8.5 add, where WordPress, Laravel and Symfony stand, and the tools that find and fix it all.

14 min read

The short version

  • PHP 7.4 has had no security fixes since 28 November 2022, yet it still runs roughly one in five PHP websites.
  • Go straight to PHP 8.5. It is supported until 31 December 2029, and PHP 8.0 to 8.2 are already end of life or close to it.
  • Almost everything that breaks is in PHP 8.0 and 8.1: stricter comparisons, errors instead of warnings, removed functions and null handling. PHP 8.2 to 8.5 mostly add deprecations.
  • Find the problems before you change anything: composer why-not php 8.5, PHPCompatibility and PHPStan with the target version set.
  • Let Rector do the mechanical edits, keep a human on the review, and run tests on both versions until cut-over.

Why PHP 7.4 sites need to move now

PHP 7.4 was released in November 2019 and received its last security release on 28 November 2022. Every PHP vulnerability found since, including October’s critical PHP2Shell flaws, is unpatched in 7.4 and always will be. The NCSC’s advice during PHP2Shell was to update immediately or take systems offline, and for a 7.4 site only the second option was available.

It is still a very common version. W3Techs data for 4 November 2026 puts PHP 7 on 26.2% of PHP websites, and PHP 7.4 accounts for 73.5% of those, which works out at roughly 19% of all PHP sites. That is a lot of businesses, agencies and WordPress installs running a runtime that has been out of support for four years.

The pressure is now coming from several directions at once:

  • Hosts are retiring it. Ubuntu 20.04, the last Ubuntu LTS to ship PHP 7.4, left standard support in 2025, and managed hosts have been removing 7.4 from their control panels throughout 2026, often with a few weeks’ notice.
  • Your dependencies left long ago. Laravel 8 was the last to support 7.4 and has been end of life since January 2023. Symfony 6.4, the oldest supported Symfony, needs PHP 8.1. Payment SDKs, mail libraries and most Composer packages have followed.
  • Security questionnaires ask. Cyber Essentials expects supported software, and clients’ procurement teams increasingly ask which PHP version a site runs.

Compare that with the destination. PHP 8.5 was released in November 2025, gets bug fixes until the end of 2027 and security fixes until 31 December 2029. See the PHP end-of-life dates for every version.

Which version to target

PHP 8.5. Not 8.1 or 8.2 because they feel like a smaller step: PHP 8.2 reaches end of life on 31 December 2026, so you would be upgrading twice. Not 8.6 because it is not out yet. It is due on 19 November 2026, framework and hosting support take a few months to settle, and the move from 8.5 to 8.6 is small compared with what you are about to do. Our latest PHP version article keeps track of both.

If you run your own servers, the version your distribution ships matters, because it decides whether you need a third-party repository:

DistributionPHP in the standard repositories
Ubuntu 26.04 LTSPHP 8.5
Ubuntu 24.04 LTSPHP 8.3
Ubuntu 22.04 LTSPHP 8.1
Debian 13PHP 8.4
Debian 12PHP 8.2

On anything other than Ubuntu 26.04, the usual answer is Ondřej Surý’s packages (the ondrej/php PPA on Ubuntu, deb.sury.org on Debian), which provide every supported PHP version side by side. That also lets you install 8.5 next to 7.4 and switch a site between them with a configuration change, which is the cheapest rollback plan there is.

Step one: find out what stands in the way

Before touching any code, find out how big the job is. Three tools answer that in an afternoon.

Composer tells you which packages block you

# Which packages (and which of their dependencies) refuse to run on PHP 8.5?
composer why-not php 8.5

# Which direct dependencies have newer releases that might fix it?
composer outdated --direct

why-not lists every package whose composer.json says it will not run on 8.5, and the chain of packages that depend on it. Most are fixed by updating. The ones to worry about are packages with no newer release: check the repository, and if nothing has happened for two or three years, plan to replace it.

PHPCompatibility lists removed and changed functions

PHPCompatibility is a set of PHP_CodeSniffer rules that knows which functions, arguments and syntax were removed or deprecated in each version. It runs on the code without executing it, so it covers the corners your tests do not:

# The plugin registers the ruleset with PHP_CodeSniffer
composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer require --dev phpcompatibility/php-compatibility

# Report every removed function, changed signature and deprecation up to PHP 8.5
vendor/bin/phpcs -p src/ --standard=PHPCompatibility --runtime-set testVersion 8.5

Expect a long list on a 7.4 codebase. Sort it by error versus warning: errors are things that will not run on 8.5, warnings are deprecations you can schedule.

PHPStan finds the behaviour changes

PHPCompatibility cannot see that strlen($maybeNull) will start logging deprecations, or that a comparison will change its answer. PHPStan can, as long as you tell it which PHP version to analyse for:

# phpstan.neon: analyse the code as PHP 8.5 would run it, even on a 7.4 machine
parameters:
    level: 0
    phpVersion: 80500
    paths:
        - src

Start at level 0 and raise it one level at a time. Even level 0 catches undefined properties and calls to functions that no longer exist.

PHP 8.0: where most of the breakage is

PHP 8.0 was the first new major version in five years, and it used the opportunity to fix behaviour that had been “wrong but tolerated” since PHP 4. If an upgrade from 7.4 goes badly, it is almost always one of the following. Full details are in the official PHP 8.0 upgrade notes.

String-to-number comparisons changed meaning

Comparing a number with a non-numeric string used to convert the string to a number (so 'foo' became 0). Now the number is converted to a string instead. The result: 0 == 'foo', 0 == '' and in_array('abc', [0]) are all false on PHP 8.

// PHP 7.4: true. PHP 8.0 and later: false.
var_dump(0 == 'foo');

// A real example from a permissions check: on 7.4 this granted access
// to anyone whose role was a non-numeric string, because 'admin' == 0.
if ($user->roleId == 0) {
    // ...
}

// Fix: compare like with like, and use === where you can
if ((int) $user->roleId === 0) {
    // ...
}

This is the change that worries us most, because nothing is logged. A permission check, a routing rule or a “has this field been filled in” test quietly gives a different answer. Grep for == 0, == '' and in_array( without a third argument, and look at each one.

Warnings became exceptions

A large number of mistakes that produced a warning and a null on 7.4 now throw a TypeError or Error, which stops the request unless something catches it:

// PHP 7.4: warning, returns null and carries on.
// PHP 8.0+: TypeError, the request stops.
strlen([]);

// PHP 7.4: "A non-numeric value encountered" warning, evaluates to 0.
// PHP 8.0+: TypeError "Unsupported operand types: string * int".
$total = 'abc' * 2;

// PHP 7.4: silently created a stdClass. PHP 8.0+: Error.
$order = null;
$order->total = 10;

The same applies to passing the wrong type to almost any built-in function, doing arithmetic on arrays or non-numeric strings, using an array as an array key, and calling parent:: in a class with no parent. On the plus side, these are loud: you will find them quickly in staging if your tests or your click-through cover the code path. The risk is code paths that only run monthly, such as a report or an invoice run.

Notices became warnings, and the default error level changed

Reading an undefined variable, array key or property is now a Warning rather than a Notice, and the default error_reporting is E_ALL. Code that relied on undefined keys being quietly null still works, but on a 7.4 codebase it will flood the error log. Make sure display_errors is off in production, then use the log as a to-do list: ?? and isset() fix nearly all of it.

Removed functions and syntax

  • each(), create_function(), __autoload(), money_format(), get_magic_quotes_gpc(), hebrevc(), convert_cyr_string() and restore_include_path() are gone.
  • Curly-brace string offsets ($str{0}) and the (real) and (unset) casts are gone.
  • implode($pieces, $glue) with the arguments reversed no longer works.
  • A method with the same name as its class is no longer a constructor. Rename it __construct().
  • match is a reserved word, so a function or constant called match breaks.
  • #[ now starts an attribute, so a comment that begins #[ is no longer a comment.
  • Nested ternaries need brackets, and . now binds less tightly than + and -, so 'Total: ' . $a + $b means something different.

PHPCompatibility finds every one of these, and Rector fixes most of them.

Resources became objects

cURL, GD, OpenSSL, XML parsers, sockets and zlib handles are now objects (CurlHandle, GdImage and so on) rather than resources. The functions still work, but is_resource() now returns false for all of them:

$ch = curl_init($url);

// PHP 7.4: $ch is a resource. PHP 8.0+: $ch is a CurlHandle object,
// so this check now always fails.
if (!is_resource($ch)) {
    throw new RuntimeException('Could not start cURL');
}

// Fix: the functions return false on failure, so test for that
if ($ch === false) {
    throw new RuntimeException('Could not start cURL');
}

PHP 8.1 did the same for FTP, IMAP, LDAP, PostgreSQL and finfo; PHP 8.4 for DBA, ODBC and SOAP. Search for is_resource( and get_resource_type( across the codebase.

Other 8.0 changes worth knowing

  • PDO throws exceptions by default. The default error mode changed from silent to PDO::ERRMODE_EXCEPTION. Code that checked return values for false now gets a PDOException instead. Usually an improvement, but it changes which code path runs on a failed query.
  • Named arguments. Harmless unless you call call_user_func_array() with an array that has string keys: those keys are now treated as parameter names.
  • Sorting is stable. Elements that compare equal keep their original order. Output that depended on the old unstable order (rare, but it happens with reports) changes.
  • Float-to-string conversion ignores the locale. (string) 1.5 is always "1.5", even under a locale that uses a comma. Code that worked around the old behaviour may now double-convert.
  • @ no longer silences fatal errors, and the track_errors setting and $php_errormsg variable are gone. Use error_get_last().
  • Magic method signatures are checked. A __toString() that declares a return type other than string, or a __get() with two parameters, is now a fatal error.

PHP 8.1: the deprecation that floods your logs

PHP 8.1 has one change that affects almost every 7.4 codebase and a handful of smaller ones. The full list is in the PHP 8.1 upgrade notes.

Passing null to built-in functions

Passing null to a built-in function parameter that is not nullable is deprecated. That sounds minor until you realise how much old code does it: trim($_POST['name']) when the field is missing, strlen($row['notes']) when the column is NULL, htmlspecialchars($maybeNull) in a template.

// PHP 8.1+: "Deprecated: trim(): Passing null to parameter #1 ($string)
// of type string is deprecated" whenever the field is missing.
$name = trim($_POST['name']);

// Fix: decide what a missing value means, and say so
$name = trim($_POST['name'] ?? '');

The code still works on 8.5, but it is scheduled to become a TypeError in PHP 9, and in the meantime a busy site can write gigabytes of deprecation notices. PHPStan at level 2 or above reports every case, and Rector has a rule that adds the ?? '' for you, though you should still decide whether an empty string is the right meaning for “missing” in each case.

PDO returns real integers and floats

With MySQL using emulated prepared statements (PDO’s default) or with SQLite, integer and float columns now come back as PHP int and float rather than strings. Most code does not care. JSON APIs do:

$row = $pdo->query('SELECT id, stock FROM products LIMIT 1')->fetch(PDO::FETCH_ASSOC);

echo json_encode($row);
// PHP 7.4 (MySQL with emulated prepares, the default):  {"id":"42","stock":"7"}
// PHP 8.1+:                                             {"id":42,"stock":7}

A mobile app or JavaScript front end that expected "42" and does a strict comparison against it will break. DECIMAL columns stay as strings, so prices are usually unaffected, but check any API response that includes an ID or a count. Set PDO::ATTR_STRINGIFY_FETCHES to true if you need the old behaviour while clients catch up.

MySQLi throws exceptions by default

Like PDO in 8.0, the mysqli extension now reports errors as mysqli_sql_exception rather than returning false. Procedural mysqli_query() code that checked for false and showed a friendly message now throws instead. Call mysqli_report(MYSQLI_REPORT_OFF) to restore the old behaviour temporarily, then fix the error handling properly.

Smaller 8.1 changes

  • htmlspecialchars() and htmlentities() now escape single quotes by default (ENT_QUOTES). Output is safer, but tests that compare HTML strings may need updating.
  • Classes that implement a built-in interface such as ArrayAccess, Iterator, Countable or JsonSerializable get a deprecation notice unless their methods declare the expected return types. Add the types, or add #[\ReturnTypeWillChange] if the class also has to run on PHP 7.
  • Implementing Serializable without __serialize() and __unserialize() is deprecated.
  • strftime(), gmstrftime(), date_sunrise(), the mhash*() functions and FILTER_SANITIZE_STRING are deprecated. They are still present in 8.5, so this is schedulable, not urgent.
  • Converting a float with a fractional part to an integer implicitly (for example using 1.9 as an array key) is deprecated.
  • Writing to $GLOBALS as a whole array is no longer allowed. Reading it and writing individual keys still works.
  • Static variables in methods are now shared with child classes that inherit the method without overriding it. Occasionally this changes a counter or cache.

PHP 8.2 to 8.5: mostly deprecations

From here on the changes are smaller and mostly deprecations, which log a notice but keep working. They still matter, because PHP 9 is expected to turn them into errors, and because a log full of deprecations hides the warnings you do need to see.

PHP 8.2

  • Dynamic properties are deprecated: assigning to a property the class never declared. Very common in older code. Declare the property, or mark the class #[\AllowDynamicProperties].
  • ${var} string interpolation is deprecated:
// Deprecated since PHP 8.2, removed in PHP 9
echo "Hello ${name}";

// Fine
echo "Hello {$name}";
  • utf8_encode() and utf8_decode() are deprecated. Use mb_convert_encoding().
  • strtolower(), strtoupper(), ucfirst() and friends no longer follow the locale. They only convert ASCII, so code that relied on setlocale() to upper-case accented characters needs mb_strtoupper().
  • Callables written as "self::method", "parent::method" or ["static", "method"] are deprecated.
  • str_split('') returns an empty array rather than [''].

PHP 8.3

  • get_class() and get_parent_class() without an argument are deprecated.
  • range() is stricter: a step of 0, or arrays and objects as boundaries, now throw.
  • Incrementing a non-numeric string with ++ is deprecated.
  • unserialize() emits warnings rather than notices for bad input.
  • Assigning to a negative index in an empty array now continues from that index: $a[-5] = 'x'; $a[] = 'y'; gives key -4, not 0.

PHP 8.4

  • Implicitly nullable parameters are deprecated. This is the one you will hit most from 8.4, because it was the normal way to write an optional object parameter for years:
// Deprecated since PHP 8.4
public function find(int $id = null): ?Product

// Fix: make the type nullable explicitly
public function find(?int $id = null): ?Product
  • The IMAP, OCI8, PDO_OCI and Pspell extensions were moved out of PHP to PECL. If the application reads mailboxes with imap_* functions or talks to Oracle, install them separately or plan a replacement.
  • E_STRICT is deprecated, round() rejects invalid modes, and exit() behaves like a function (which matters only if it was called with an odd argument).
  • mysqli_ping(), mysqli_kill() and mysqli_refresh() are deprecated.
  • Changing session.sid_length and session.sid_bits_per_character is deprecated.

PHP 8.5

  • The non-canonical casts (integer), (boolean), (double) and (binary), and the backtick operator, are deprecated:
// Deprecated since PHP 8.5
$qty = (integer) $input;
$ok  = (boolean) $flag;
$out = `ls -la`;

// Fine
$qty = (int) $input;
$ok  = (bool) $flag;
$out = shell_exec('ls -la');
  • Using null as an array key or in array_key_exists() is deprecated. Use ''.
  • Casting a float that cannot be represented as an integer (NAN, INF, or values beyond PHP_INT_MAX) now warns.
  • The new array_first() and array_last() functions conflict with any helper of the same name in your code. The same goes for the new Uri\ namespace.
  • __sleep() and __wakeup() are soft-deprecated in favour of __serialize() and __unserialize().
  • $http_response_header is deprecated; use http_get_last_response_headers().
  • ReflectionProperty::setAccessible() and ReflectionMethod::setAccessible() are deprecated (they have done nothing since 8.1), as are curl_close(), imagedestroy() and similar functions that free objects which are now freed automatically.
  • The numeric values of several PDO::FETCH_* constants changed. Code that hard-coded the numbers rather than the constants breaks.
  • Opcache is now always built in. If your deployment adds zend_extension=opcache.so, that line now produces a warning and should be removed.

In exchange, 8.5 brings the pipe operator, clone() with property overrides, a standards-compliant URI parser and #[\NoDiscard]. The PHP 8.5 upgrade notes have the complete list.

Frameworks, WordPress and the dependency problem

In our experience PHP itself is rarely what makes a 7.4 upgrade expensive. The expensive part is the framework version the application is stuck on, and the packages that stopped being maintained. Here is where the major platforms stand in November 2026:

PlatformPosition on PHP 7.4 and 8.5
WordPressWordPress 7.0 still runs on PHP 7.4 and fully supports PHP 8.5 (the “beta support” label was retired in May 2026). The recommended minimum is PHP 8.3. Core is not the problem; plugins and themes are.
LaravelLaravel 13 needs PHP 8.3 to 8.5; Laravel 12 runs on 8.2 to 8.5 and gets security fixes until February 2027. Laravel 8 was the last version to run on PHP 7.4, so a 7.4 Laravel app is on an end-of-life framework and needs stepping through each major version.
SymfonySymfony 6.4 LTS needs PHP 8.1 and gets security fixes until November 2027. Symfony 7.4 LTS needs PHP 8.2 and is supported until November 2029. Symfony 8.1 needs PHP 8.4.
Composer packagesMost actively maintained packages dropped PHP 7.4 in 2022 or 2023. The ones that still claim to support it are often the ones nobody has updated since, which is a different kind of risk.

For a WordPress site, run PHPCompatibility over wp-content, update everything, then test the site on PHP 8.5 in staging. Any plugin or theme that still fails and has not seen an update in a year or two should be replaced rather than patched, because the next update would overwrite your fix. See our WordPress PHP upgrade service for how we handle WooCommerce extensions and custom themes.

For Laravel and Symfony, upgrade the framework one major version at a time and run the test suite at each step. Each framework’s upgrade guide lists its own breaking changes, and trying to do PHP and three framework majors in a single branch is how upgrades stall. Our Laravel and Symfony upgrade pages describe the sequence we use.

Let Rector do the typing

Rector rewrites PHP code according to rules, and it has a rule for most of the changes above: removing create_function(), replacing $str{0}, adding ? to implicitly nullable parameters, swapping (integer) for (int), declaring dynamic properties, and hundreds more. One config covers the whole journey:

<?php
// rector.php
use Rector\Config\RectorConfig;

return RectorConfig::configure()
    ->withPaths([__DIR__ . '/src'])
    // Every PHP 8.0 to 8.5 upgrade rule in one go...
    ->withPhpSets(php85: true);
    // ...or, for a large legacy codebase, one step at a time:
    // ->withPhpLevel(1), then 2, 3... reviewing each diff

Run it with --dry-run first and read the diff. On a large legacy codebase, apply the rules a level at a time and commit each batch separately, so a reviewer can look at one kind of change at a time and a bad change is easy to revert. Rector cannot tell you whether $this->emial was a typo, or whether == 0 was meant to match an empty string. Those judgements are still a person’s job, which is why we never run it unattended.

A process that doesn’t break production

  1. Measure first. Composer, PHPCompatibility and PHPStan, as above. Now you know whether this is a week or a quarter.
  2. Add tests to the paths that make money. Login, checkout, forms, APIs, imports and scheduled jobs. If there are no tests, write characterisation tests that record what the application does today, so a changed comparison or a new TypeError fails in CI rather than in front of a customer.
  3. Fix the PHP 8.0 and 8.1 changes with Rector and the static analysis output, in small reviewed commits. Keep the application running on 7.4 throughout: nothing in this step requires PHP 8 syntax.
  4. Upgrade dependencies and the framework to versions that support PHP 8.5, one major version at a time.
  5. Run CI on both 7.4 and 8.5 until the suite is green on 8.5, then deploy to a staging server on 8.5 and compare the error logs with production.
  6. Switch production with PHP 8.5 installed alongside 7.4, so rolling back is a configuration change. Watch the logs for a week, then clear the remaining deprecations.

You can keep shipping features throughout. There is no long-lived upgrade branch drifting away from the main one, and no big-bang release day.

Frequently asked questions

Can I upgrade directly from PHP 7.4 to PHP 8.5?

Yes. There is no need to run PHP 8.0, 8.1 and so on in production along the way. The code changes do follow the version order, which is why tools such as Rector apply one version’s rules at a time, but the server can go from 7.4 straight to 8.5 once the code is ready.

How long does a PHP 7.4 to 8.5 upgrade take?

A small, well-maintained application with tests can be done in a few days. A large application with no tests, an old framework version or abandoned packages can take several weeks. The dependency check and static analysis described in this article tell you which of those you have within an hour or two.

Should I wait for PHP 8.6 instead?

No. PHP 8.6 is due on 19 November 2026, but the jump from 8.5 to 8.6 is small, and everything that makes 7.4 to 8.x hard is in 8.0 and 8.1. Get to 8.5, which is supported until 31 December 2029, and treat 8.6 as a routine follow-up.

Is PHP 8.5 faster than PHP 7.4?

Usually, yes. PHP 8.0 brought a JIT compiler and every release since has improved the engine, so most applications see lower response times and memory use after the move. Treat that as a bonus rather than the reason to upgrade: the reason is that PHP 7.4 has had no security fixes since November 2022.

My host offers extended support for PHP 7.4. Is that enough?

It buys time, and it is better than running 7.4 with no fixes at all. It does not fix the bigger problem: the frameworks, CMS plugins and Composer packages your site depends on dropped PHP 7.4 years ago, so you are missing their security fixes too. Use the extra time to do the upgrade, not to avoid it.

My site is WordPress. Does any of this apply to me?

All of it, but the work lands in plugins and themes rather than code you wrote. WordPress 7.0 still runs on PHP 7.4 and fully supports PHP 8.5, so core is fine. Run the PHPCompatibility scan over wp-content, update everything, and replace any plugin that has not been updated for PHP 8. See our WordPress PHP upgrade service for the usual suspects.