PHP 8.6 at a glance
PHP 8.6.0 was released on November 19, 2026. The headline additions are Partial Function Application, a new Duration class, a Polling API, a clamp() function, a SortDirection enum and default values for readonly properties. This guide covers every major change with code examples, the deprecations and breaking changes, and what to check before you upgrade. Coming from an older version? Read our guides to PHP 8.5 new features, changes and deprecations and What's New in PHP 8.4.
What are the new features in PHP 8.6?
Partial Function Application
Partial Function Application lets you supply some arguments now and leave the rest for later using ? placeholders. The result is a Closure, and the function only runs once the remaining arguments are passed.
// PHP 8.5 and older
fn ($version) => version_compare($version, '8.6', '>=')
// PHP 8.6
version_compare(?, '8.6', '>=')The new clamp() function
clamp() replaces the nested max(min()) pattern. It works with any comparable value, including the new Duration class.
var_dump(clamp(-10, 0, 100)); // int(0)
var_dump(clamp(50, 0, 100)); // int(50)
var_dump(clamp(110, 0, 100)); // int(100)The \Time\Duration class
Duration represents elapsed time as a stopwatch measures it. It is independent of any date or timezone, covers a range of more than 250 years and has nanosecond precision. It is a good fit for timeouts, retry delays and benchmark timings.
use Time\Duration;
$delay = $baseDelay->add($step->multiplyBy(2 ** $attempt));
$delay = min($delay, Duration::fromSeconds(30));
time_nanosleep($delay->seconds, $delay->nanoseconds);Polling API (Io\Poll)
The new Io\Poll API watches many streams at once. It uses epoll, kqueue, event ports or WSAPoll, depending on the platform. It avoids the connection limit of stream_select(), which typically cannot handle more than 1024 connections. It is meant as a base for event loop libraries such as ReactPHP and AMPHP.
SortDirection enum
PHP now ships a built-in SortDirection enum with Ascending and Descending cases. Libraries can accept it in their public APIs instead of each inventing integers, strings or booleans. Passing a wrong value now gives a clear TypeError instead of failing deep inside a method.
$qb->orderBy('name', SortDirection::Descending);Readonly property defaults
Readonly properties, including those in readonly classes, can now declare a default value. You no longer need a constructor only to assign a fixed value.
final readonly class SlugRule implements Rule
{
public string $parser = SlugParser::class;
}Stream error handling
Stream operations can now throw a StreamException or fail silently instead of emitting warnings. Errors are structured StreamError objects with a StreamErrorCode enum case, the wrapper name and the affected path or URL. You can also read them later with stream_last_errors().
Parameter doc comments and Reflection
Function and method parameters can now have their own doc comments, readable with ReflectionParameter::getDocComment(). The new ReflectionProperty::isReadable() and isWritable() methods report whether a property can be read or written in a given scope, taking visibility, hooks and initialization state into account.
Other PHP 8.6 improvements
#[\Override]now works on class constants and enum cases.- Enums can implement the
__debugInfo()magic method. - Properties of objects stored in constants can be modified directly, such as
Config::DEFAULTS->timeout = 30. - New
Uri\Rfc3986\UriBuilderandUri\WhatWg\UrlBuilderclasses build URIs from their components. - The Sodium extension adds post-quantum key encapsulation (X-Wing and ML-KEM-768), IP address encryption and the SHAKE and TurboSHAKE functions.
- TLS streams support session resumption, external pre-shared keys and TLS 1.3 early data (0-RTT).
- New
mysqli::quote_string()method, matchingPDO::quote(). pack()andunpack()accept the<and>endianness modifiers.- JSON error messages now include the location of the error in the input.
- New
error_include_argsINI setting for function arguments in error messages. - New
grapheme_strrev()function,IntlNumberRangeFormatterclass andZipArchive::openString()andcloseString()methods.
PHP 8.6 performance improvements
PHP 8.6 compiles array_map() with a first-class callable or partial application callback into a loop. It also makes printf() and JSON encoding faster and caches stateless closures.
PHP 8.6 deprecations and breaking changes
These functions are deprecated, with the replacement to use instead:
mb_ereg(),mb_split()and the mbstring regex functions → PCRE functions with theumodifieris_double(),is_long(),is_integer()anddoubleval()→is_float(),is_int()andfloatval()spl_object_hash()→spl_object_id()spl_classes()→ReflectionExtension::getClassNames()strcoll()andSORT_LOCALE_STRING→ theCollatorclass from the intl extension- Objects passed where an array is expected in
array_walk(),http_build_query()and similar → convert the object first withget_object_vars()
Other things that are deprecated:
- Using
returninside afinallyblock. - Returning a value from
__construct()or__destruct(), or making them generators. - Using
letorisas the name of a class, function or constant. - A third argument to
define(). - Custom session handlers that do not implement both
create_sid()andvalidateId(). metaphone(),mysqli_get_charset()andmysqli_stmt_init().
Changes in behaviour that can break existing code:
trim(),ltrim()andrtrim()now also strip the form feed character (\f) by default.fclose(),file_put_contents()andcopy()now returnfalsewhen flushing or closing the stream fails, instead of ignoring it.- Many functions now throw a
ValueErrorfor out-of-range values, invalid flags or strings containing NUL bytes.
Sessions are more secure by default
In PHP 8.6, session.use_strict_mode and session.cookie_httponly are enabled, and session.cookie_samesite is set to Lax. This is the change most likely to affect a real application, especially login and cross-site flows. Test them before you deploy.
How to upgrade to PHP 8.6
- Read the official migration guide on php.net.
- Search your code for the deprecated functions in the table above.
- Test sessions, login flows and any custom session handlers.
- Check that your framework and extensions support PHP 8.6. If you use Laravel, our guide to Laravel 13 new features, improvements and what developers should know covers the framework side.
- Run your full test suite on a staging server before you upgrade production.
PHP 8.6 FAQ
When was PHP 8.6 released?
PHP 8.6.0 was released on November 19, 2026.
What are the main new features in PHP 8.6?
Partial Function Application, the \Time\Duration class, the Io\Poll Polling API, the clamp() function, the SortDirection enum and default values for readonly properties.
What replaces mb_ereg() in PHP 8.6?
The mbstring regex functions such as mb_ereg() and mb_split() are deprecated because the Oniguruma library is no longer maintained. Use PCRE functions with the u modifier instead.
Does PHP 8.6 change session settings?
Yes. session.use_strict_mode and session.cookie_httponly are now enabled by default, and session.cookie_samesite is Lax.
Is PHP 8.6 safe to upgrade to?
Check the deprecations and the stricter session defaults first, then test on a staging server. Most deprecations only emit notices, but the new ValueError cases and the changed return values of fclose(), file_put_contents() and copy() can affect existing code.
Source
All details in this article come from the official PHP 8.6 Release Announcement on php.net. For the complete list of changes, read the PHP 8.6 ChangeLog and migration guide linked there.




