PHP 8.6: new features, deprecations and breaking changes
PHP 8.6 was released on 19 November 2026. Partial function application, clamp(), readonly property defaults, Io\Poll and Time\Duration, plus the session and ValueError changes to check before upgrading.
On this page
PHP 8.6.0 was released on 19 November 2026. It is supported with active bug fixes until 31 December 2028 and security fixes until 31 December 2030. The release is about convenience in everyday code and safer defaults. Below are the headline additions and the changes most likely to affect an upgrade from 8.5. For the complete list, see the official release page.
Partial function application
You can now call a function with placeholders: ? stands for one missing argument, and ... for all remaining ones. The result is a Closure that takes the missing arguments.
$slugify = str_replace(' ', '-', ?); // fn (string|array $subject) => str_replace(' ', '-', $subject)
echo $slugify('hello sunny world'); // hello-sunny-world
$log = sprintf('[%s] %s', 'info', ...); // remaining arguments forwarded
It pairs naturally with the pipe operator from PHP 8.5:
$result = $input
|> trim(...)
|> str_replace(' ', '-', ?)
|> strtolower(...);
clamp()
A built-in for the max($min, min($max, $value)) dance:
clamp(150, 0, 100); // 100
clamp(-5, 0, 100); // 0
Readonly properties with default values
final class RetryPolicy
{
public readonly int $attempts = 3;
public readonly int $delayMs = 250;
}
Previously a readonly property had to be set in the constructor.
SortDirection, Time\Duration and Io\Poll
SortDirectionis a built-in enum for ascending or descending order, for type-safe sort options in your own APIs.Time\Durationrepresents elapsed, stopwatch-style time with nanosecond precision, which suits timeouts and benchmarks better than floats of seconds.Io\Pollwatches many streams with the operating system’s native mechanism (epoll, kqueue), without the file-descriptor limits ofstream_select(). It matters mostly to async libraries and long-running servers.
Changes to check before upgrading
Safer session defaults. session.use_strict_mode and session.cookie_httponly are now on, and session.cookie_samesite defaults to Lax. Most apps benefit, but check flows that rely on session cookies in cross-site POSTs (some payment and single sign-on callbacks) or JavaScript reading the session cookie.
More ValueErrors. Many functions now throw ValueError for out-of-range values, invalid flags or strings containing NUL bytes, instead of truncating silently. Run your test suite with the new version early.
Small behaviour changes. trim() and friends strip form feeds by default; fclose(), file_put_contents() and copy() return false when flushing or closing fails.
Deprecations worth fixing now:
returninside afinallyblock.- Returning a value from
__construct()or__destruct(). - The mbstring regex functions (
mb_ereg(),mb_split()and related); switch topreg_*with theumodifier. - The
is_double(),is_long(),is_integer()anddoubleval()aliases;spl_object_hash()(usespl_object_id());strcoll()andSORT_LOCALE_STRING(useCollator). let,isand_as identifiers, which are reserved for future syntax.- Custom session handlers without
create_sid()andvalidateId().
Should you upgrade now?
For new projects, yes. For existing apps, wait for your framework and key packages to declare 8.6 support (check composer why-not php 8.6), then follow the upgrade checklist. PHP 8.2 stops receiving security fixes on 31 December 2026, so if you are on 8.2 or older, plan the move now.
Sources
- PHP 8.6 release announcement, php.net
- PHP 8.6 UPGRADING notes, php-src