PHP 8.6 is the new version of PHP, released on 19 November 2026. If you write PHP for a living, it brings a few features you’ll use every day, like partial function application and a built-in clamp() function. It also changes some defaults that can quietly affect a live site, especially around sessions.
Take a developer friend we’ll call Rohit. He builds Laravel and WordPress projects for small businesses in Lucknow. Every November, a client asks him the same question: “Should we upgrade PHP now?” Last year he upgraded one site on day one and spent an evening fixing a payment plugin that wasn’t ready. This year he wants to know exactly what changed before he touches anything.
This guide is for developers like Rohit. I went through the official PHP 8.6 UPGRADING notes from the php-src repository, the php.net release announcements and the RFCs behind each feature. I also built PHP 8.6 and ran the code examples in this article, so you can copy them with confidence.
PHP 8.6 at a glance
PHP 8.6.0 went through three alpha, three beta and several release candidate builds between July and November 2026. The php.net announcement for RC7 confirmed the first stable release for 19 November 2026.
| Item | PHP 8.6 |
|---|---|
| Release date | 19 November 2026 |
| Active support | Expected until 31 December 2028 |
| Security fixes | Expected until 31 December 2030 |
| Biggest new feature | Partial function application (? and ... placeholders) |
| New functions | clamp(), grapheme_strrev(), mysqli_quote_string(), stream_last_errors() and more |
| New classes and enums | Time\Duration, SortDirection, the Io\Poll polling API, StreamException |
| Default changes | Stricter, safer session cookie settings |
| Deprecations | Returning from finally, returning values from constructors, spl_object_hash(), is_double(), mbstring regex and more |
The support dates follow PHP’s current policy: two years of active support from the release, then two years of security fixes, each ending on 31 December. php.net lists PHP 8.5 with active support until 31 December 2027 and security fixes until 31 December 2029, so 8.6 sits one year after that.
10 new features in PHP 8.6 you’ll actually use
Every example below ran on PHP 8.6.0RC7, the final release candidate, and the output shown is what PHP printed.
1. Partial function application
This is the headline feature of PHP 8.6. You can now call a function with some arguments filled in and a ? placeholder for the rest. Instead of running the function, PHP gives you back a new callable that waits for the missing value.
$makeSlug = str_replace(' ', '-', ?);
echo $makeSlug('hello php world'); // hello-php-world
function priceWithGst(float $price, float $rate, string $currency): string {
return $currency . number_format($price * (1 + $rate), 2);
}
$withGst18 = priceWithGst(?, 0.18, '₹');
echo $withGst18(1000); // ₹1,180.00
$fixedPrice = priceWithGst(500, ...);
echo $fixedPrice(0.05, '₹'); // ₹525.00 The ? stands for exactly one argument, while ... stands for all the remaining ones. Before PHP 8.6, you had to write a small arrow function such as fn($s) => str_replace(' ', '-', $s) for the same result. The partial function application RFC has the full rules.
2. The clamp() function
clamp() keeps a value inside a range. If the value is below the minimum, you get the minimum. If it’s above the maximum, you get the maximum.
var_dump(clamp(101, min: 0, max: 100)); // int(100)
var_dump(clamp(-5, 0, 100)); // int(0)
var_dump(clamp(42, 0, 100)); // int(42)
clamp(5, 10, 1);
// ValueError: clamp(): Argument #2 ($min) must be smaller than or equal to argument #3 ($max) So the old max(0, min(100, $value)) trick finally has a readable replacement. It’s handy for discount percentages, pagination limits and star ratings. It also works with any values PHP can compare, including strings and DateTimeImmutable objects.
3. Readonly properties with default values
Readonly properties can now have a default value, so you no longer need a constructor just to set a fixed value.
final class Invoice {
public readonly string $currency = 'INR';
public function __construct(public readonly float $amount) {}
}
$invoice = new Invoice(2500);
echo $invoice->currency; // INR 4. #[\Override] on class constants
The #[\Override] attribute, added for methods in PHP 8.3, now works on class constants and enum cases too. If the parent class doesn’t have that constant, PHP throws an error. As a result, a typo or a renamed constant in a parent class can’t break your code silently.
class BaseGateway {
public const TIMEOUT = 30;
}
class RazorpayGateway extends BaseGateway {
#[\Override]
public const TIMEOUT = 60;
} 5. Time\Duration for exact time spans
PHP 8.6 adds a new Time\Duration class for time spans with nanosecond precision. It’s immutable, so every operation returns a new object.
use Time\Duration;
$timeout = Duration::fromSeconds(90);
$total = $timeout->add(Duration::fromMilliseconds(1500));
echo $total->seconds; // 91
echo $total->nanoseconds; // 500000000
$slot = Duration::fromIso8601DurationString('PT1H30M');
echo $slot->seconds; // 5400
echo Duration::compare($timeout, $slot); // -1 It also has fromMinutes(), fromHours(), sub(), multiplyBy(), divideBy(), negate() and absolute(). For API timeouts and booking slot lengths, this is much cleaner than passing raw integers around.
6. Writing properties on objects stored in constants
Since PHP 8.1 you could store an object in a constant, but you couldn’t change its properties. Now you can.
class Config { public string $env = 'local'; }
const APP_CONFIG = new Config();
APP_CONFIG->env = 'production';
echo APP_CONFIG->env; // production 7. Stream errors as exceptions
File and network functions like fopen() and file_get_contents() have always produced warnings, which forced many of us to use the @ operator. PHP 8.6 adds a new stream errors API. Set error_mode in the stream context, and failures throw a StreamException instead.
$ctx = stream_context_create([
'stream' => ['error_mode' => StreamErrorMode::Exception],
]);
try {
$data = file_get_contents('/no/such/file.txt', false, $ctx);
} catch (StreamException $e) {
echo 'Caught: ' . $e->getMessage();
// Caught: Failed to open stream: No such file or directory
} The other modes are StreamErrorMode::Error (the old warning behaviour) and StreamErrorMode::Silent. You can also read past errors with the new stream_last_errors() function.
8. JSON errors now show the location
When json_decode() fails, json_last_error_msg() and JsonException now tell you where the problem is.
json_decode("{\n \"name\": \"Rohit\",\n \"city\" \"Lucknow\"\n}");
echo json_last_error_msg(); // Syntax error near location 3:10 In this example, the missing colon is on line 3, column 10. If you’ve ever debugged a large webhook payload from a payment gateway, you’ll appreciate this one.
9. SortDirection enum and parameter doc comments
PHP 8.6 adds a built-in SortDirection enum with two cases, SortDirection::Ascending and SortDirection::Descending. Libraries can now share one standard type for sort order instead of each inventing their own strings or constants.
You can also put a doc comment on a single function parameter and read it with ReflectionParameter::getDocComment():
function sendOtp(
/** Indian mobile number with country code */
string $phone
) {}
$param = (new ReflectionFunction('sendOtp'))->getParameters()[0];
echo $param->getDocComment(); // /** Indian mobile number with country code */ 10. Safer session defaults
This change needs no new code, but it affects almost every PHP site that uses sessions. Three session settings have new defaults:
| Setting | Old default | PHP 8.6 default | What it does |
|---|---|---|---|
session.use_strict_mode | 0 | 1 | Rejects session IDs the server never created, which blocks session fixation |
session.cookie_httponly | 0 | 1 | JavaScript can no longer read the session cookie |
session.cookie_samesite | (empty) | Lax | The session cookie isn’t sent on most cross-site requests |
These are good security defaults. However, if a payment gateway posts back to your site from its own domain, the user’s session cookie may not arrive with that POST request because of SameSite=Lax. Test your payment return pages before you upgrade. Also, these are only defaults: if your server’s php.ini or your code already sets any of these three values, that setting still applies.
Smaller additions worth knowing
mysqli_quote_string()andmysqli::quote_string(), which escape a string and add the surrounding quotes in one callgrapheme_strrev()in the intl extension, which reverses a string safely even with emoji or Hindi characters- A new
Io\Pollpolling API, aimed at event-loop libraries that currently usestream_select() __debugInfo()is now allowed on enumsReflectionProperty::isReadable()andisWritable()- An
error_include_argsINI setting that adds function arguments to warning messages (off by default) - TLS session resumption and TLS 1.3 early data for OpenSSL streams
<and>endianness modifiers inpack()andunpack()- The built-in development server now accepts the HTTP QUERY method
- Faster
json_encode(),array_map()with multiple arrays,str_pad(),str_split()and several other functions
PHP 8.6 deprecations and breaking changes
Deprecations don’t break your code today. They show a Deprecated notice, and the feature is expected to be removed in PHP 9.0. So treat them as a to-do list, not an emergency.
Deprecations you’re most likely to hit
| Deprecated in PHP 8.6 | Use this instead |
|---|---|
return inside a finally block | Return after the try/finally |
Returning a value from __construct() or __destruct() | A bare return; or no return |
spl_object_hash() | spl_object_id() |
is_double() | is_float() |
is_integer() and is_long() | is_int() |
doubleval() | floatval() |
strcoll() and SORT_LOCALE_STRING | Collator from the intl extension |
mbstring regex functions such as mb_ereg() and mb_split() | preg_* functions with the /u modifier |
Passing an object to array_walk() or http_build_query() | Pass an array |
metaphone() and spl_classes() | No direct replacement needed for most code |
More than 16 filters in a php://filter URL | Set filter.max_filter_count if you really need more |
When I ran old-style code on PHP 8.6, the notices looked like this:
Deprecated: Returning from a finally block is deprecated
Deprecated: Returning a value from a constructor is deprecated
Deprecated: Function spl_object_hash() is deprecated since 8.6, consider using spl_object_id() instead
Deprecated: Function is_double() is deprecated since 8.6, use is_float() instead The mbstring regex deprecation has a clear reason: the Oniguruma library behind it is no longer maintained. The full list, including some rarely used names such as let and is as class names, is in the PHP 8.6 deprecations RFC.
Backward-incompatible changes to check
Most code will run unchanged, but these changes from the official UPGRADING notes can catch you out:
trim(),ltrim()andrtrim()now remove the form feed character (\f) by default.- The session defaults change described above, which can affect payment gateway returns and cross-site form posts.
- Custom session handlers that accepted session IDs without checking storage now need
validateId()andcreate_sid(), orsession.use_strict_modeset back to 0. - Many functions now throw a
ValueErrorfor invalid arguments or strings containing NUL bytes, instead of returningfalsewith a warning. - On a hard out-of-memory error, PHP now calls
abort(), so the process exit code changes from 1 to 134. This matters if your monitoring or queue workers check exit codes. - Read-only DOM properties such as
DOMNode::$nodeTypeare now declared with asymmetric visibility, which changes the error message if you try to write to them.
PHP 8.6 support timeline
PHP 8.2 stops getting security fixes on 31 December 2026, and PHP 8.4 leaves active support on the same day. So if a client site still runs 8.2, it’s the most urgent upgrade on your list, even before you think about 8.6.
How to upgrade to PHP 8.6 safely
This is the routine Rohit now follows, and the one I use for client sites.
- Check your current version. Run
php -von the server, or look under Tools > Site Health > Info > Server in WordPress. - Check your framework and plugins. Look at the PHP versions listed on the WordPress.org page of each plugin you rely on, and in your theme’s documentation. For Laravel or Symfony, check which PHP versions your framework release officially supports before you switch.
- Copy the site to staging. Most cPanel and hPanel hosts let you pick a PHP version per domain, so set the staging copy to 8.6 first.
- Turn on full error reporting on staging. Set
error_reporting = E_ALLand log errors to a file, then watch for the newDeprecatednotices. - Run static analysis. Tools like PHPStan, Psalm or Rector can find deprecated functions such as
is_double()andspl_object_hash()across a whole codebase in minutes. - Test sessions and payments. Log in, log out, place a test order and complete a test payment, so you can confirm the new
SameSite=Laxdefault doesn’t drop the session on the gateway’s return URL. - Switch production at a quiet hour. Keep the old PHP version selected in your notes, so you can switch back from the hosting panel in a minute if something breaks.
You don’t need to rush, though. PHP 8.5 gets active support until 31 December 2027, and PHP 8.4 until 31 December 2026. On the other hand, if your site still runs PHP 8.2, it stops getting security fixes on 31 December 2026, so plan that upgrade now.
What this means for WordPress and Laravel sites
For a typical WordPress site, the risk usually sits in older plugins, not in WordPress itself. Abandoned plugins that still call is_double() or use mbstring regex will start filling your error log with deprecation notices. For Laravel projects, check that every Composer package you use has a release that allows PHP 8.6 in its composer.json before you switch.
My take on PHP 8.6
I’ve been writing PHP for over 13 years, and partial function application is the change I’m most excited about since constructor property promotion in PHP 8.0. It makes array_map() and callback-heavy code much easier to read, and I think it’ll show up in Laravel codebases quickly.
clamp() is a small thing, but I’ve written max(0, min(100, $x)) in almost every project, so I’m glad to retire it. The JSON error location is the same story: tiny change, real time saved.
The session defaults are the part I’d watch most carefully. They’re the right call for security, but they can break a payment flow quietly, and a broken checkout costs a client money. So I won’t move a live store to 8.6 on release day. I’ll test on staging first and wait for the first patch release, 8.6.1, on busy ecommerce sites.
Frequently asked questions
When was PHP 8.6 released?
PHP 8.6 was released on 19 November 2026, as announced on php.net with the final release candidate (RC7). It’s expected to get active support until 31 December 2028 and security fixes until 31 December 2030.
What is the biggest new feature in PHP 8.6?
Partial function application. You can call a function with a ? placeholder for a missing argument, or ... for all remaining arguments, and PHP returns a new callable instead of running the function.
Will my WordPress site work on PHP 8.6?
It depends mainly on your plugins and theme. Test the site on a staging copy with PHP 8.6 and full error logging, and update or replace any plugin that throws errors.
Do deprecated functions stop working in PHP 8.6?
No. Deprecated functions such as spl_object_hash() and is_double() still work in PHP 8.6. They only show a Deprecated notice, and they’re expected to be removed in PHP 9.0.
Should I upgrade to PHP 8.6 right away?
Upgrade your development and staging environments now, so you can find problems early. For busy production sites, especially online stores, it’s safer to wait for the first patch release and test payments and logins first.
PHP 8.6: final word
PHP 8.6 is a developer-friendly release. Partial function application, clamp(), readonly defaults, Time\Duration and better JSON errors make everyday code shorter and easier to read. The safer session defaults are a real security win, but they’re also the change most likely to surprise a live site.
Rohit’s plan for his clients is simple. He’s moved his own projects and staging sites to PHP 8.6 this week, cleaned up the deprecation notices, and scheduled live sites one by one after testing logins and payments.
If you run WooCommerce, PHP versions matter there too: WooCommerce has announced that version 11.6 will need PHP 8.1 or newer, as I explain in WooCommerce 11.3: developer changes to test before you update. If you’re also trying AI tools to speed up an upgrade like this, read my comparison of AI coding agents vs AI code assistants. And if you’d rather have someone test and upgrade your PHP, WordPress or Laravel site for you, get in touch with me.