PHP versions

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
  1. Partial function application
  2. clamp()
  3. Readonly properties with default values
  4. SortDirection, Time\Duration and Io\Poll
  5. Changes to check before upgrading
  6. Should you upgrade now?

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

  • SortDirection is a built-in enum for ascending or descending order, for type-safe sort options in your own APIs.
  • Time\Duration represents elapsed, stopwatch-style time with nanosecond precision, which suits timeouts and benchmarks better than floats of seconds.
  • Io\Poll watches many streams with the operating system’s native mechanism (epoll, kqueue), without the file-descriptor limits of stream_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:

  • return inside a finally block.
  • Returning a value from __construct() or __destruct().
  • The mbstring regex functions (mb_ereg(), mb_split() and related); switch to preg_* with the u modifier.
  • The is_double(), is_long(), is_integer() and doubleval() aliases; spl_object_hash() (use spl_object_id()); strcoll() and SORT_LOCALE_STRING (use Collator).
  • let, is and _ as identifiers, which are reserved for future syntax.
  • Custom session handlers without create_sid() and validateId().

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

Found a mistake or something out of date? Tell us and we will fix it. See our editorial policy.

A good place to start

What are you working on?

Tools, guides, PHP versions and the archive.

ToolJSON ↔ PHP arrayConvert JSON to a PHP array literal with short or array() syntax, or turn a PHP array back into JSON. Runs in your browser; nothing is uploaded.ToolSerialized data inspectorRead PHP serialized strings as a tree, find wrong string lengths after a search-and-replace, and rebuild them with correct byte counts. Parsed safely in your browser.ToolComposer constraint testerSee exactly which versions a Composer constraint such as ^2.1, ~1.4 or >=8.1 <8.4 allows, in plain English, and test versions against it.ToolPHP date() format builderBuild a PHP date() or DateTime::format() string with a live preview in any time zone, plus a reference for every format character.ToolPHP upgrade checklistPick your current and target PHP versions and get every breaking change, deprecation and tooling step in between, as a checklist you can copy.GuideAllowed memory size exhaustedWhat PHP's memory_limit fatal error means, how to tell a real leak from a big job, and fixes for the usual causes: loading whole tables, unbounded arrays, Composer and recursion.GuideComposer dependency conflictsA step-by-step way to read Composer's conflict output, find the package that is blocking you, and fix it without --ignore-platform-reqs or deleting the lock file.Guidecomposer install vs updatecomposer install reproduces composer.lock; composer update rewrites it. Here is what each command does, when to use which, and a safe production deploy routine.GuideComposer uses the wrong PHP versionComposer says "your php version (8.1.x) does not satisfy that requirement" when your server runs 8.3? The cause is usually the CLI binary, config.platform.php, or platform_check.php.GuideEloquent N+1 queriesHow to spot N+1 queries in Laravel, fix them with eager loading, withCount() and constrained loads, and make Laravel throw an exception the next time one slips in.GuideHeaders already sentThe warning names the file and line that produced output. Here is how to read it, the five usual culprits (BOM, whitespace, echo, warnings, closing tags) and fixes that do not just hide it.GuideWriting a talk proposalWhat reviewers look for in a call-for-papers submission: a specific title, an abstract for attendees, notes for the committee, and a talk-sized idea. With a worked example and a checklist.GuideLaravel queue jobs not runningJobs dispatched but never processed, stuck in the jobs table, or running old code? Work through the connection, the queue name, the worker, failed jobs and deploy restarts.PHP versionsWhat's new in PHP 8.4PHP 8.4 (released 21 November 2024) brought property hooks, public private(set) visibility, new without parentheses, lazy objects, an HTML5 DOM parser and array_find(). Plus the deprecations that matter.PHP versionsWhat's new in PHP 8.5PHP 8.5 (released 20 November 2025) added the |> pipe operator, a standards-compliant URI extension, clone() with property overrides, #[\NoDiscard] and array_first()/array_last().PHP versionsWhat's new in PHP 8.6PHP 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.GuidePHP array to JSONWhy json_encode() sometimes gives you an object instead of a list, how to keep floats and slashes intact, and how to catch the silent false that malformed UTF-8 returns.GuideDuplicate webhooks in PHPWebhook providers retry, so the same event can arrive twice. Verify the signature, record the event ID with a unique key, answer fast and process in a queue: a pattern that works in plain PHP, Laravel and Symfony.GuidePHPStan baseline for legacy codeGenerate a PHPStan baseline, stop new errors from getting in, then raise the level step by step. A tested routine for old PHP codebases.GuidePSR-4 autoloadingHow PSR-4 maps namespaces to folders, how to configure it in composer.json, and why "Class not found" happens: case, typos, a stale autoloader or a namespace that does not match the path.GuideSerialized data broken after search-replaceChanging a domain name with SQL REPLACE() or sed corrupts PHP serialized strings because their byte lengths no longer match. Here is how to spot it and repair it safely.GuideUpgrade PHP with RectorUpgrade a PHP application one version at a time: pin the baseline, let Rector rewrite syntax, let PHPStan find what Rector cannot, and prove it with tests before you switch runtimes.PHP versionsSupported PHP versionsRelease, active support and end-of-life dates for every PHP version.ArchiveSunshinePHP talk archive 2013–2020Talk titles and speakers from eight years of the Miami PHP conference.ArchiveSpeaker indexEveryone who spoke at SunshinePHP, A to Z.