Short answer: PHP 8.6 is due for general availability on 19 November 2026. Its headline features are partial function application (str_replace(' ', '-', ?) returns a closure), default values on readonly properties, a native clamp() function, a Time\Duration class, a new Io\Poll polling API, exception-based stream errors and a SortDirection enum. It removes no extensions, but it deprecates a long list of old aliases (is_integer(), is_double(), doubleval(), spl_object_hash() and more) and makes PHP sessions secure by default, and that last change is the one most likely to affect a live app.
This guide puts 8.6 next to 8.5 and 8.4, the two versions most teams are running right now, so you can see what you gain, what you have to fix and whether the jump is worth it today. Every change below was checked against the UPGRADING notes in php-src, the RFCs that introduced it and the php.net release page.
PHP 8.4 vs 8.5 vs 8.6 at a glance
| PHP 8.4 | PHP 8.5 | PHP 8.6 | |
|---|---|---|---|
| Released | 21 Nov 2024 | 20 Nov 2025 | 19 Nov 2026 (scheduled) |
| Active support until | 31 Dec 2026 | 31 Dec 2027 | 31 Dec 2028 |
| Security fixes until | 31 Dec 2028 | 31 Dec 2029 | 31 Dec 2030 |
| Main theme | Object model | Readable, chainable code | Functional ergonomics and I/O |
| Headline features | Property hooks, asymmetric visibility, lazy objects, new without parentheses |
Pipe operator |>, clone with, URI extension, #[\NoDiscard] |
Partial function application, readonly defaults, clamp(), Time\Duration, polling API |
| New array helpers | array_find(), array_find_key(), array_any(), array_all() |
array_first(), array_last() |
None (but array_map() with a PFA or first-class callable is compiled into a loop) |
| Errors and debugging | #[\Deprecated] attribute |
Backtraces on fatal errors, get_error_handler() |
Structured stream errors, JSON error positions, error_include_args INI |
| Security defaults | Bcrypt cost raised from 10 to 12 | No change | Sessions: strict mode, HttpOnly and SameSite=Lax on by default |
| Extensions removed | IMAP, OCI8, PDO_OCI, pspell (moved to PECL) | None | None |
| Notable deprecations | Implicitly nullable types, E_STRICT, lcg_value() |
Backtick operator, (integer)/(double) casts, curl_close(), null array offsets |
is_integer(), is_double(), doubleval(), spl_object_hash(), return in finally, mbregex |
Support dates come from the php.net supported versions page, which gives every branch two years of active support and two more of security fixes. The 8.6 dates follow the same rule.
What is new in PHP 8.6
Partial function application (PFA)
This is the feature that will change how everyday PHP looks. Call a function with ? in place of an argument and PHP does not run it. It returns a Closure that is waiting for the missing values. ... stands for "all remaining arguments".
function price(float $amount, float $taxRate, string $currency): string
{
return sprintf('%s %.2f', $currency, $amount * (1 + $taxRate));
}
$inr = price(?, 0.18, 'INR'); // Closure(float $amount): string
echo $inr(1000); // INR 1180.00
$withTax = price(?, 0.18, ...); // Closure(float $amount, string $currency): string
echo $withTax(50, 'USD'); // USD 59.00
The closure keeps the real parameter names and types of the original function, so reflection, IDEs and static analysers see a proper signature instead of a loose callable. Named placeholders work too: price(1000, taxRate: ?, currency: 'INR').
Where PFA really pays off is with callbacks and the pipe operator from 8.5. In 8.5, any pipe step that needs more than one argument has to be an arrow function, and since an RFC erratum in August 2025 that arrow function also has to be wrapped in parentheses:
// PHP 8.5
$slug = $title
|> trim(...)
|> strtolower(...)
|> (fn (string $s): string => str_replace(' ', '-', $s));
// PHP 8.6
$slug = $title
|> trim(...)
|> strtolower(...)
|> str_replace(' ', '-', ?);
// Callbacks get shorter too
$clean = array_map(str_replace(["\r", "\n"], ' ', ?), $lines);
It is also faster than it looks. When a PFA call with one open slot sits directly on the right of |>, the compiler removes the closure and emits a plain function call. And 8.6 compiles array_map() with a first-class callable or PFA callback into an ordinary foreach loop, so there is no closure overhead at all.
The gotcha: arguments you do supply are evaluated once, when the closure is created, not every time it is called. An arrow function behaves the other way round.
function logLine(string $time, string $message): string
{
return "[$time] $message";
}
$log = logLine(date('H:i:s'), ?); // date() runs right now
sleep(5);
echo $log('Import finished'); // still shows the time from 5 seconds ago
$log = fn (string $m) => logLine(date('H:i:s'), $m); // date() runs on every call
A handful of functions that depend on the caller's scope cannot be partially applied, the same ones that already refuse first-class callable syntax: compact(), extract(), func_get_args(), get_defined_vars() and friends.
Readonly properties with default values
Up to 8.5, public readonly string $name = 'x'; was a compile error. The ban was never technical. The original readonly RFC simply called such a property "not particularly useful". Interface properties, added in 8.4, made it useful: a class can now satisfy a get-only interface property with a fixed value and no constructor.
interface PaymentGateway
{
public string $code { get; }
}
final readonly class RazorpayGateway implements PaymentGateway
{
public string $code = 'razorpay';
public int $timeoutSeconds = 15;
}
echo new RazorpayGateway()->code; // razorpay
The default counts as the one allowed initialisation. It is applied before the constructor runs, so the constructor can no longer overwrite it:
final class Rule
{
public readonly string $parser = JsonParser::class;
public function __construct(string $parser)
{
$this->parser = $parser; // Error: Cannot modify readonly property Rule::$parser
}
}
If you need "a default unless the caller passes something", keep using constructor promotion with a default argument: public function __construct(public readonly string $parser = JsonParser::class) {}.
The new clamp() function
clamp($value, $min, $max) returns $value when it is inside the range (both ends included) and the nearest bound when it is not. It replaces the max($min, min($max, $value)) pattern that every codebase has somewhere, usually with the arguments in the wrong order once.
// Before
$perPage = max(1, min(100, (int) ($_GET['per_page'] ?? 20)));
// PHP 8.6
$perPage = clamp((int) ($_GET['per_page'] ?? 20), 1, 100);
clamp(150, 0, 100); // 100
clamp('d', 'c', 'g'); // 'd' (normal PHP comparison rules)
clamp(5, 10, 1); // ValueError: $min must be smaller than or equal to $max
It accepts anything PHP can compare, including DateTimeImmutable objects, and it throws a ValueError when $min is greater than $max or either bound is NAN. One upgrade risk: if your project or one of your dependencies declares a global function called clamp() without a function_exists() guard, it will hit a "cannot redeclare" fatal error on 8.6. Search for function clamp( before you upgrade.
Time\Duration
Time\Duration is an immutable value object for elapsed time, stored as seconds plus nanoseconds. Unlike DateInterval, it has no days or months, so it never depends on time zones or daylight saving. The php.net release page says it covers a range of more than 250 years with nanosecond precision. It is meant for timeouts, retry delays and benchmark timings, the places where code currently passes around a bare integer and hopes everyone agrees on the unit.
use Time\Duration;
$timeout = Duration::fromMilliseconds(1500);
$timeout->seconds; // 1
$timeout->nanoseconds; // 500000000
$retryDelay = Duration::fromSeconds(1)->add(Duration::fromMilliseconds(250)->multiplyBy($attempt));
$retryDelay = min($retryDelay, Duration::fromSeconds(30)); // Durations are comparable
time_nanosleep($retryDelay->seconds, $retryDelay->nanoseconds);
Factory methods exist for nanoseconds, microseconds, milliseconds, seconds, minutes and hours, and there are add(), sub(), multiplyBy(), divideBy(), negate() and a static compare().
The Io\Poll polling API
stream_select() is built on select(), which on most systems cannot watch more than 1,024 file descriptors and gets slower as the list grows. The new Io\Poll\Context picks the best mechanism the operating system offers (epoll on Linux, kqueue on macOS and BSD, event ports on Solaris, WSAPoll on Windows) and gives it one object-oriented interface.
use Io\Poll\{Context, Event};
$server = stream_socket_server('tcp://0.0.0.0:9000');
$poll = new Context(); // Backend::Auto
$poll->add(new StreamPollHandle($server), [Event::Read]);
while (true) {
foreach ($poll->wait() as $watcher) {
$stream = $watcher->getHandle()->getStream();
// accept new clients, read, write, or $watcher->remove()
}
}
Most application developers will never write this loop themselves. It matters because event-loop libraries such as ReactPHP and AMPHP, and the servers built on them, can drop their own extension-based backends and rely on core PHP instead.
Stream errors as exceptions
Filesystem and network functions have always reported problems as warnings plus a false return, which is why so much PHP code is littered with @ and error_get_last(). In 8.6 a stream context can ask for exceptions instead:
$context = stream_context_create([
'stream' => ['error_mode' => StreamErrorMode::Exception],
]);
try {
$config = file_get_contents('/etc/app/config.json', false, $context);
} catch (StreamException $e) {
foreach ($e->getErrors() as $error) {
// $error->code is a StreamErrorCode case, e.g. StreamErrorCode::NotFound
$logger->error($error->message, ['wrapper' => $error->wrapperName, 'path' => $error->param]);
}
}
Each StreamError carries an enum code, the wrapper name, the severity and the affected path or URL, so you can react to "not found" and "permission denied" differently without parsing message strings. StreamErrorMode::Silent stores errors for stream_last_errors() without printing anything. You cannot set these options on the default context with stream_context_set_default(), which throws a ValueError if you try.
SortDirection enum
A global, unbacked enum with two cases, SortDirection::Ascending and SortDirection::Descending. Core sort functions do not take it. It exists so that query builders, collection libraries and APIs can share one type instead of each inventing its own 'asc'/'desc' strings or boolean flags.
$query->orderBy('created_at', SortDirection::Descending);
Smaller additions worth knowing
#[\Override]on class constants and enum cases, so a renamed parent constant becomes a compile error instead of a silent new constant.__debugInfo()on enums to control whatvar_dump()shows.- Writing to properties of objects stored in constants, for example
self::CONFIG->debug = true;. mysqli::quote_string(), which returns an escaped value with the quotes already added.grapheme_strrev()for reversing user-visible characters, emoji included.ReflectionProperty::isReadable()andisWritable(), which answer "could code in this scope read or write this property?" for a given class scope and object.- JSON errors now say where they happened in both
json_last_error_msg()andJsonException. - The
error_include_argsINI setting (off by default) shows the arguments of the failing call in error messages, with the same redaction rules as stack traces. - Post-quantum crypto in sodium: X-Wing and ML-KEM768 key encapsulation when PHP is built against libsodium 1.0.22 or later.
- The built-in development server now accepts the HTTP
QUERYmethod.
Feature comparison: what each version added
| Area | PHP 8.4 | PHP 8.5 | PHP 8.6 |
|---|---|---|---|
| Classes and properties | Property hooks, public private(set), interface properties, lazy objects |
Asymmetric visibility on static properties, final promoted properties, #[\Override] on properties |
Readonly defaults, #[\Override] on constants, __debugInfo() on enums |
| Functional style | None | Pipe operator |>, closures and first-class callables in constant expressions |
Partial function application with ? and ... |
| Object copies | None | clone($obj, ['prop' => $value]) |
None |
| Syntax shortcuts | new Foo()->bar() |
(void) cast |
Object property writes in constants |
| Standard library | array_find() family, mb_trim(), mb_ucfirst(), request_parse_body() |
array_first(), array_last(), get_exception_handler() |
clamp(), SortDirection, grapheme_strrev() |
| Dates and time | DateTime::createFromTimestamp() |
None | Time\Duration |
| URLs | None | Built-in Uri extension (RFC 3986 and WHATWG) |
UriBuilder, UrlBuilder, host and URI type detection |
| I/O and networking | None | Persistent cURL share handles | Io\Poll API, stream errors, TLS session resumption, socket keepalive options |
| HTML and XML | HTML5 parser in Dom\HTMLDocument |
None | DOM "readonly" properties become real private(set) |
| Attributes | #[\Deprecated] |
#[\NoDiscard], #[\DelayedTargetValidation] |
None |
| Debugging | Better Closure and WeakReference debug output |
Backtraces on fatal errors | JSON error positions, error_include_args |
Behaviour changes that can break your app
None of these produce a syntax error, which is exactly why they are easy to miss in testing.
Sessions are now secure by default
Three php.ini defaults changed. If your php.ini or framework already sets them explicitly, nothing happens. If it relies on the old defaults, it will notice:
| Setting | Old default | PHP 8.6 default | What breaks |
|---|---|---|---|
session.use_strict_mode |
0 | 1 | Custom session handlers that accept an ID with no stored session need validateId() and create_sid() |
session.cookie_httponly |
0 | 1 | JavaScript that reads the session cookie via document.cookie |
session.cookie_samesite |
(unset) | Lax | Cross-site POST flows that need the session, such as some payment gateway callbacks and SSO returns |
The payment callback case deserves a real test. If a gateway POSTs the customer back to your site and you expect them to still be logged in, set session.cookie_samesite=None together with session.cookie_secure=1 for that app, or better, stop depending on the session in that callback and verify the gateway's signature instead.
Other quiet changes
trim(),ltrim()andrtrim()now strip form feed (\f) by default.fclose(),file_put_contents()andcopy()returnfalsewhen the final flush fails. Previously the failure was ignored, so code that never checked the return value may now see failures it was missing all along.preg_grep()returnsfalseon a PCRE error instead of a partial array, matching the otherpreg_*functions.base_convert(),bindec(),hexdec()andoctdec()raise a notice when the result loses precision.- Many functions now throw
ValueErrorfor out-of-range or NUL-byte arguments instead of truncating silently, among themfile_exists(),is_file(),getenv(),parse_str(),sleep(),number_format()andsetlocale(). session_encode()returns an empty string for an empty session rather thanfalse.SplFileObject::fgets()andnext()behave differently around the current line and EOF, which matters if you mixfgets()withcurrent().- A hard out-of-memory error now calls
abort(), so the process exits with code 134 instead of 1. Update any supervisor or monitoring rule that matches on exit codes.
Deprecated in PHP 8.6
Deprecations still work in 8.6 but emit E_DEPRECATED, and they are expected to be removed in PHP 9.0. Most have a one-line replacement:
| Deprecated | Use instead |
|---|---|
is_integer(), is_long() |
is_int() |
is_double() |
is_float() |
doubleval() |
floatval() |
spl_object_hash() |
spl_object_id() |
spl_classes() |
ReflectionExtension::getClassNames() |
strcoll(), SORT_LOCALE_STRING |
Collator::compare(), Collator::sort() |
metaphone() |
A userland phonetic matching library |
mysqli_get_charset(), mysqli_stmt_init() |
mysqli_character_set_name(); mysqli::prepare() |
Returning a value from __construct() or __destruct() |
Return nothing |
return inside a finally block |
Return after the try/finally |
Third argument to define() |
Remove it (case-insensitive constants are long gone) |
Objects passed to array_walk(), http_build_query(), mb_convert_variables() |
Pass get_object_vars($object) |
SplFileObject::fgetcsv(), fputcsv() and the CSV control methods |
fgetcsv() and fputcsv() on a stream |
Mbregex (mb_ereg*()) |
preg_*() with the u modifier; Oniguruma is no longer maintained |
let, is or _ as class, function or constant names |
Rename; these are reserved for future syntax |
Session handlers without create_sid() and validateId() |
Implement both methods |
The SPL list is longer: several ArrayIterator methods inherited from ArrayObject (asort(), ksort(), getFlags(), setFlags() and others) are deprecated as well, and so are ReflectionProperty::setValue() calls with an object of the wrong class.
What was removed in 8.4, 8.5 and 8.6
A common worry with a new release is "what will disappear". For the last three versions the answer is: very little.
| Version | Removed | Impact |
|---|---|---|
| PHP 8.4 | IMAP, OCI8, PDO_OCI and pspell extensions, unbundled to PECL | Install them from PECL if you still use them. IMAP users usually move to a userland library. |
| PHP 8.5 | No extensions removed | Deprecations only |
| PHP 8.6 | No extensions removed | Deprecations only (see above) |
Actual removals of deprecated functions are batched for PHP 9.0. That makes 8.6 a good moment to clear your deprecation log, because everything flagged there is on the list for the next major version.
Performance in PHP 8.6
There is no single "X percent faster" number for 8.6, and you should distrust any article that quotes one without a benchmark. The changes are many targeted improvements:
printf()calls that only use%sand%dare compiled into string interpolation.array_map()with a first-class callable or PFA callback becomes aforeachloop at compile time.- A cache for stateless closures, faster argument passing to known constructors (
new self()), and faster deep recursion. - Faster
json_encode()for arrays and objects, especially withJSON_PRETTY_PRINT. - Faster
str_pad(),str_split(),array_sum()on integer arrays,array_unshift(),array_intersect()and others. - JIT now works on thread-safe (ZTS) builds on Apple Silicon, and the TAILCALL VM is faster and now enabled on Windows Clang builds.
Measure your own app. Run your test suite and a representative request benchmark on both versions before and after; framework-heavy apps usually see small single-digit gains, while code heavy on array_map() or JSON can see more.
Should you upgrade now?
| You are on | Recommendation |
|---|---|
| PHP 8.2 | Move now. Security support ends on 31 December 2026. Go to 8.4 or 8.5, not straight to 8.6. |
| PHP 8.3 | Plan the move to 8.4 or 8.5 this quarter. Active support already ended in December 2025. |
| PHP 8.4 | You are safe until the end of 2028. Active support ends on 31 December 2026, so put 8.5 or 8.6 on the roadmap for early 2027. |
| PHP 8.5 | Wait for 8.6.1 or 8.6.2 and for your framework, extensions and hosting to declare support. Then upgrade. |
Whatever you choose, do not run a x.0 release in production on day one. Extensions such as Xdebug, Redis, Imagick and Swoole often ship 8.6-compatible builds days or weeks later, and the first patch release usually fixes a handful of engine bugs found by early adopters.
PHP 8.6 upgrade checklist
- Turn on all deprecation notices in development (
error_reporting=E_ALL) under your current version and clear them first. - Search the code base for the risky names:
grep -rnE "function clamp\(|is_integer\(|is_double\(|doubleval\(|spl_object_hash\(|mb_ereg" src/. - Decide your session cookie policy. Set
session.use_strict_mode,session.cookie_httponlyandsession.cookie_samesiteexplicitly so the new defaults cannot surprise you, then test login, logout and every third-party callback. - Check custom session handlers for
validateId()andcreate_sid(). - Look for code that ignores the return value of
file_put_contents(),copy()orfclose()on network or remote storage. - Confirm that Composer dependencies, PHP extensions, your Docker base image or hosting panel and your static analysis and Rector versions all support 8.6.
- Run the full test suite on 8.6 in CI next to your current version, then roll out to staging, then to production.
FAQ
When is PHP 8.6 released?
PHP 8.6.0 is scheduled for general availability on 19 November 2026, after three alphas, three betas and seven release candidates. The last one, RC7, came out on 12 November 2026.
What is the biggest new feature in PHP 8.6?
Partial function application. Writing ? in place of an argument returns a typed closure, which makes callbacks and pipe chains much shorter. Readonly property defaults and clamp() are the other features most developers will use straight away.
Does PHP 8.6 remove anything?
No extensions or functions were removed in 8.6. It only deprecates features, such as is_integer(), doubleval(), spl_object_hash() and returning from a finally block. Deprecated features are expected to be removed in PHP 9.0.
Is PHP 8.6 backward compatible with PHP 8.5?
Mostly. Code that runs on 8.5 without deprecation notices will usually run on 8.6. The changes most likely to bite are the new secure session cookie defaults, a userland global function named clamp(), and functions that now throw ValueError instead of quietly accepting bad input.
How long will PHP 8.6 be supported?
Following PHP's current release policy, 8.6 gets active support until 31 December 2028 and security fixes until 31 December 2030.
Is there a PHP 9?
Not yet. PHP 9.0 has no release date. The deprecations added across 8.x, including those in 8.6, are the list of things expected to be removed when it arrives.
How this article was researched
Written on 19 November 2026. The feature, behaviour change and deprecation lists come from the UPGRADING files on the PHP-8.4, PHP-8.5 and PHP-8.6 branches of php-src, cross-checked against the accepted RFCs on wiki.php.net (partial function application v2, clamp v2, readonly property defaults, duration class, poll API, stream errors, sort direction enum, session security defaults and the PHP 8.6 deprecations RFC) and the PHP 8.6 release page on php.net. Support dates are from php.net's supported versions page. Release candidate dates are from the PHP QA release feed. Code examples follow the syntax and error messages given in those RFCs; we did not run them on the final 8.6.0 build, which was not yet tagged when this was written. If anything here disagrees with the official PHP 8.6 manual, the manual wins. Tell us and we will fix it.
Comments 0
No comments yet. Be the first to share your thoughts.
Leave a comment