PHP 8.4 has been the current release since November 2024, and its active support ends on 31 December 2026. After that date it still receives security fixes, but no ordinary bug fixes, so a site that wants its reported problems patched has to be on 8.5. That release has been out since 20 November 2025, and the current build is 8.5.13.
The good news is that the upgrade is small. PHP 8.5 removes almost nothing and, unlike 8.0, it does not rewrite the language underneath you. What it does is deprecate a long list of small conveniences and change the behaviour of a handful of others, and nearly all of it happens quietly. Everything below comes from measurements on PHP 8.5.13 on my test server, with PHP 8.4.27 beside it for comparison, so the messages are the ones you will see.
Find out what your own code hits first
Finding most of this work takes two commands, and neither of them is part of the upgrade. They are preparation: a lint and a text search that you run to see which lines will change behaviour, so you know what to edit before you switch versions. The first is the lint you already run, with one flag added. PHP’s command-line default leaves deprecations out of error_reporting, so a plain php -l calls all six files of my demo tree clean while the same run with the level raised reports five deprecations:
|
1 |
find . -name '*.php' -print0 | sort -z | xargs -0 -n1 php -d error_reporting=E_ALL -l |
|
1 2 3 4 5 6 7 8 9 10 11 |
No syntax errors detected in ./bootstrap.php PHP Deprecated: Non-canonical cast (boolean) is deprecated, use the (bool) cast instead in ./lib/casts.php on line 4 PHP Deprecated: Non-canonical cast (integer) is deprecated, use the (int) cast instead in ./lib/casts.php on line 5 PHP Deprecated: Case statements followed by a semicolon (;) are deprecated, use a colon (:) instead in ./lib/casts.php on line 7 PHP Deprecated: Case statements followed by a semicolon (;) are deprecated, use a colon (:) instead in ./lib/casts.php on line 8 No syntax errors detected in ./lib/casts.php No syntax errors detected in ./lib/cleanup.php No syntax errors detected in ./lib/legacy.php No syntax errors detected in ./lib/storage.php PHP Deprecated: The backtick (`) operator is deprecated, use shell_exec() instead in ./lib/text.php on line 4 No syntax errors detected in ./lib/text.php |
PHP decides every one of those while it reads the file, before a single line runs. That is exactly why the lint is the right tool here: a cast and a backtick have no function name to search for.
The second command is a plain text search rather than a PHP tool. grep knows nothing about PHP; it finds the names of functions that 8.5 now deprecates, which is how you locate those calls in your own code. On the same six files:
|
1 |
grep -rnE 'curl_close\(|curl_share_close\(|finfo_close\(|imagedestroy\(|xml_parser_free\(|->setAccessible\(|mysqli_execute\(|socket_set_timeout\(|->attach\(|->contains\(|->detach\(|new ArrayObject\(|new ArrayIterator\(|__sleep|__wakeup' . |
|
1 2 3 4 5 6 7 8 9 |
./lib/cleanup.php:7: curl_close($ch); ./lib/cleanup.php:15: finfo_close($finfo); ./lib/cleanup.php:22: imagedestroy($im); ./lib/legacy.php:6: public function __sleep(): array ./lib/legacy.php:11: public function __wakeup(): void ./lib/storage.php:4: $store->attach($item); ./lib/storage.php:5: $known = $store->contains($item); ./lib/storage.php:6: $store->detach($item); ./lib/storage.php:12: return new ArrayObject($config); |
Neither command says anything about the deprecations that only appear when a line actually runs. For those, run one request with the level raised and read the output:
|
1 |
php -d error_reporting=E_ALL -d display_errors=1 index.php |
What stops or warns
This is the short half, and it holds the changes that make code do something other than what it did. None of them remove a function, so none of them announce themselves as a missing call.
| What the code does | What happens now |
|---|---|
class_alias('ArrayObject', 'array') |
Fatal error: Cannot use "array" as a class alias as it is reserved |
new mysqli(), then ->__construct() on it again |
Error: Cannot call constructor twice |
new ArrayObject($enumCase) |
InvalidArgumentException: Enums are not compatible with ArrayObject |
destructuring a number, as in [$a, $b] = 42; |
Warning: Cannot use int as array, and both variables become null |
casting a float too large for an int, as in (int) 1.0e20 |
Warning: The float 1.0E+20 is not representable as an int, cast occurred |
| casting NAN to an int or a string | two warnings, then 0 and "NAN" |
$xml->xpath('count(//a)'), where the expression is not a node set |
a warning, and false instead of an empty array |
ini_set('disable_classes', 'ArrayObject') |
the setting is gone, and ini_set() returns false |
Check the class-alias row if you use class_alias() to make short names: “array” and “callable” were never types you could alias honestly, and 8.5 stops pretending. Two more changes in this section used to work. An enum case can no longer be the backing store of an ArrayObject. And a loose comparison between an enum case and a boolean now follows (bool) in every case, which is silent, and which only shows up when the other side of the comparison is a variable rather than a literal.
The deprecations the compiler catches
PHP reports this whole group while it reads the file, so the lint above is what finds them, and a php -l without the raised level reports nothing at all. First come four cast spellings that were never canonical:
|
1 2 3 4 |
Deprecated: Non-canonical cast (boolean) is deprecated, use the (bool) cast instead Deprecated: Non-canonical cast (integer) is deprecated, use the (int) cast instead Deprecated: Non-canonical cast (double) is deprecated, use the (float) cast instead Deprecated: Non-canonical cast (binary) is deprecated, use the (string) cast instead |
The replacement is a one-word edit in every case, and the two forms have always meant the same thing, so there is nothing to re-test:
|
1 2 |
$flag = (boolean) $value; // deprecated in 8.5 $flag = (bool) $value; // the canonical form |
Next comes a case label that ends with a semicolon instead of a colon. Its message names the character to change:
|
1 |
Deprecated: Case statements followed by a semicolon (;) are deprecated, use a colon (:) instead |
The backtick operator goes the same way. It was always only a shorter spelling of shell_exec(), and PHP has deprecated the spelling rather than the act:
|
1 |
Deprecated: The backtick (`) operator is deprecated, use shell_exec() instead |
One detail about this group matters if you write your own error handler. Because PHP decides these at compile time, their messages arrive before any code runs. In a file that also has runtime deprecations, the compiler’s lines come first, in file order, so a handler that expects lines in the order the code runs will look wrong here.
Objects that now free themselves
The largest group of deprecations is one idea repeated across extensions. A handle that used to need an explicit close now frees itself when the variable goes out of scope, so the close call has turned into a no-op with a notice attached.
| Deprecated call | What to do |
|---|---|
curl_close(), curl_share_close() |
delete the line, the handle frees itself |
finfo_close() |
delete the line too |
imagedestroy() |
and this one |
xml_parser_free() |
and this one |
finfo_buffer($f, $data, $flags, $context) |
drop the fourth argument, PHP ignores it |
$store->attach(), ->contains(), ->detach() |
offsetSet(), offsetExists(), offsetUnset() |
mysqli_execute() |
mysqli_stmt_execute() |
socket_set_timeout() |
stream_set_timeout() |
ReflectionMethod::setAccessible(), ReflectionProperty::setAccessible() |
delete it, it has had no effect since 8.1 |
openssl_pkey_derive($key, $key, $length) |
drop the length argument, the curve decides it |
Measured, each message names its own reason, and the reasons are not the same:
|
1 2 |
Deprecated: Function curl_close() is deprecated since 8.5, as it has no effect since PHP 8.0 Deprecated: Function finfo_close() is deprecated since 8.5, as finfo objects are freed automatically |
For that group the fix is deletion, not a replacement. The call has done nothing since PHP 8.0, so the notice asks you to remove a no-op rather than fix behaviour. SplObjectStorage behaves differently: those three methods still do their job and only the names have moved.
Constants and DSNs that moved
The next set of changes is a replacement value in each case, rather than a deleted line.
| Deprecated | Use instead |
|---|---|
PDO::MYSQL_ATTR_INIT_COMMAND and the other driver-prefixed constants |
Pdo\Mysql::ATTR_INIT_COMMAND, and the matching namespaced class for each driver |
new PDO('uri:/etc/dsn') |
a plain DSN string, not one read from a file or a URL |
DATE_RFC7231, DateTimeInterface::RFC7231 |
a format string, or RFC1123 with GMT set explicitly |
MHASH_MD5 and the other MHASH_* constants |
hash() with 'md5', plus its own algorithm names |
chr(300), ord('ab') |
use chr($n % 256), and ord($s[0]) for the byte you meant |
$row[null], array_key_exists(null, $row) |
$row[''], and array_key_exists('', $row) |
The array-offset row is the easiest to overlook, because $row[null] and $row[''] still find the same key today. That is exactly what makes the change easy to postpone. Measured, the two messages that carry a version read differently from the pattern above:
|
1 2 3 |
Deprecated: Using null as an array offset is deprecated, use an empty string instead Deprecated: Method SplObjectStorage::attach() is deprecated since 8.5, use method SplObjectStorage::offsetSet() instead Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants |
Settings, methods and operators that moved
The remaining changes each need a setting or a call replaced. None of them stop the page, and several write nothing to the log at all.
| Deprecated | Use instead |
|---|---|
the intl.error_level setting |
intl.use_exceptions, or check the return value yourself |
the register_argc_argv setting |
read $_GET or $_SERVER['QUERY_STRING'], with register_argc_argv=0 |
the report_memleaks setting |
drop it from the configuration |
incrementing a non-numeric string, as in $label++ |
str_increment($label) |
__sleep(), __wakeup() |
__serialize(), __unserialize() |
$http_response_header |
http_get_last_response_headers() |
readdir(null), rewinddir(null), closedir(null) |
pass the directory handle you mean |
Some of these print nothing at all, which is why a scan earns its place even when nothing looks broken. Setting intl.error_level, register_argc_argv or report_memleaks at runtime prints nothing. PHP also writes no message when a class declares __sleep() or __wakeup(), and none when you read $http_response_header. For all of those, the manual carries the note and nothing else does. The advice for __sleep() and __wakeup() is to add the two newer methods beside the old ones, so a class stays readable by both. Incrementing a non-numeric string does warn, and it names the replacement:
|
1 |
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead |
readdir(null) needs an argument rather than a deletion: passing null always meant “use the last opened directory”, and 8.5 asks you to name the handle instead.
What PHP 8.5 adds
The other half of the release is what you gain by upgrading, and the headline is the pipe operator, |>. It takes the value on its left and passes it as the single argument of the callable on its right, which turns a nest of calls into a readable chain:
|
1 2 3 |
$result = "Hello World" |> strlen(...); // 11 $chain = " Hello " |> trim(...) |> strtoupper(...) |> strrev(...); // OLLEH |
Two smaller additions are worth adopting in the same pass. A function whose return value matters can carry the #[\NoDiscard] attribute, and a caller that really does mean to ignore it says so with a (void) cast:
|
1 2 3 4 5 6 |
#[\NoDiscard] function concat(string $a, string $b): string { return $a . $b; } concat("a", "b"); // Warning: The return value of function concat() should // either be used or intentionally ignored by casting it as (void) $used = concat("x", "y"); // fine, the value is consumed |
The second is casts inside a constant expression, which removes a class of one-off constants people wrote to work around the old restriction. A constant can now settle its value at compile time:
|
1 |
const T1 = (int) 0.3; // 0, and it used to be a fatal error |
More of what 8.5 adds
Three more features change how you write a modern class. A property can carry #[\Override] now, so a name that was meant to override a parent is checked instead of quietly becoming a new member. Measured, a property with that attribute and no matching parent property stops at compile time:
|
1 |
Fatal error: Child2::$missing has #[\Override] attribute, but no matching parent property exists |
A constant can carry an attribute as well, including #[\Deprecated], which is the first time a constant can announce its own replacement. And clone has become a function, which lets it take a set of values to replace during the copy:
|
1 2 3 4 |
class Config { public function __construct(public readonly string $host) {} public function withHost(string $h): self { return clone($this, ['host' => $h]); } } |
The new values may only touch a property the current scope can write, so calling that form on a readonly property from outside the class raises Error: Cannot modify protected(set) readonly property Config::$host from global scope. The copy still leaves the original untouched, which is what makes the form useful for a settings object.
Two additions are about seeing what went wrong. A fatal error now carries a backtrace, so an exhausted memory limit or a timeout shows the calls that led to it instead of a single file and line. And a validation filter can be told to throw, by passing FILTER_THROW_ON_FAILURE, rather than hand back a value you then have to check:
|
1 2 3 4 5 |
PHP 8.4: Allowed memory size of 16777216 bytes exhausted (tried to allocate 4198400 bytes) in grow.php on line 2 PHP 8.5: the same line, then: Stack trace: #0 grow.php(2): str_repeat() #1 {main} |
The last two are worth a mention for completeness. A uri extension is now always present, and it adds Uri\Rfc3986\Uri and Uri\WhatWg\Url, two classes that parse a URL the way a browser does. And intl gains IntlListFormatter, which joins words with the right conjunction for a locale:
|
1 2 3 |
(new IntlListFormatter('en_US', IntlListFormatter::TYPE_AND, IntlListFormatter::WIDTH_WIDE)) ->format(['apples', 'oranges', 'pears']) // apples, oranges, and pears (new IntlListFormatter('ro_RO', ...))->format(['mere', 'pere']) // mere și pere |
On a hosting account
On a shared plan the version is a per-domain setting in the control panel, and switching back is immediate and loses nothing. So the safe order is the one the commands at the top already describe: copy the site, run the lint and the grep over the copy, run one request with the level raised and read what it prints, fix what it found, and only then move the domain.
Two things to check before you start. The extensions your code leans on have to be present on 8.5, and php -m prints the list for whichever binary you point it at. Since 8.5, PHP builds Opcache into the binary and always loads it, and it no longer ships an opcache.so at all. A zend_extension=opcache.so line left in your php.ini now fails to load, and it should come out:
|
1 |
Warning: Failed loading Zend extension 'opcache.so' (tried: /usr/lib/php/20250925/opcache.so ...) in Unknown on line 0 |
Fix the deprecations first. They cost nothing today, and they become the fatal errors of the release after this one. PHP deprecated each() in 7.2 and removed it in 8.0. It deprecated mcrypt in 7.1 and removed it in 7.2. Each deprecation buys you a window like that, and nothing tells you when it closes.