PHP turned 31 this year and, if the past month is anything to go by, it has spent a good part of that birthday getting thoroughly checked over. On November 19, the language shipped PHP 8.6 on its usual annual schedule — a release that arrives in the shadow of a nasty run of security bugs and leans hard into one clear theme: PHP is going to stop being quite so forgiving.
The headline change is not a flashy new syntax feature. It is a philosophical shift. The defaults that govern sessions, strings, and file operations — many of them inherited from a more trusting era of the web — have been tightened. Behaviors that used to fail silently now throw errors. Settings that used to leave applications exposed now ship locked down. If you run PHP in production, especially through WordPress, Laravel, or Symfony, this is a release you need to read carefully rather than simply install.
Disclosure: This article contains no affiliate links. Technical details are drawn from the official PHP 8.6 release notes and RFCs, and from reporting by The Register and the PHP Foundation.
A rough autumn set the stage
To understand why 8.6 is so security-focused, you have to look at what happened just before it. Since October, a cluster of vulnerabilities — the so-called PHP2Shell bugs — has plagued the language. In the worst cases, unauthenticated attackers could crash PHP workers or execute arbitrary code on the server. Users of every PHP-based application, WordPress included, had to scramble to patch.
The PHP core team and the PHP Foundation responded with a coordinated release of patched versions — 8.5.13, 8.4.28, 8.3.37, and 8.2.36, alongside the new 8.6 — that closed seven critical remote code execution flaws in one sweep. The Foundation also published a retrospective admitting that its consensus-driven process had stalled complex fixes for months, and promising to ship patches faster when vulnerabilities leak ahead of an agreed disclosure deadline.
Against that backdrop, a proposal that core developer Jörg Sowa filed back in June landed in 8.6 almost unnoticed. It may turn out to be the more consequential change.
The quiet proposal that changed the defaults
Sowa’s argument was simple: three settings in PHP’s session extension were designed to improve security, but they shipped with defaults that left applications “unnecessarily exposed.” Those three settings were Strict Mode, HttpOnly, and SameSite. In PHP 8.6, all three now default to their secure values.
← swipe to see all columns →
| Setting | Old default | PHP 8.6 default | Threat addressed |
|---|---|---|---|
session.use_strict_mode | Off | On | Session fixation / planted IDs |
session.cookie_httponly | Off | On | Session theft via JavaScript (XSS) |
session.cookie_samesite | Unset | Lax | Cross-site request forgery (CSRF) |
1. Strict Mode: no more planted session IDs
Previously, PHP would accept a session ID it had never issued. An attacker could plant a made-up ID on a victim and use it to gain entry. With Strict Mode on by default, PHP rejects IDs it did not create. As Sowa explained, “The built-in files handler checks whether a session file for that ID exists on disk; because an attacker-planted ID has no corresponding file, a fresh random ID is generated instead.”
2. HttpOnly: JavaScript can no longer read the cookie
PHP now adds the HttpOnly flag to its session Set-Cookie header by default. Until now, any script on the page could read the session ID — and hand it to an attacker who could then masquerade as the user. With the flag set, client-side JavaScript is locked out of that cookie.
3. SameSite: cookies withheld on cross-site requests
The server now withholds session cookies on cross-site POST requests, subrequests, and iframes. “Without it, a forged form or link on an attacker-controlled site can trigger authenticated requests using the victim’s session,” Sowa wrote. Cookies are now sent only on same-site requests and top-level GET navigations — the equivalent of clicking an ordinary link.
Taken together, these changes make session hijacking and cross-site request forgery significantly harder. They do not stop remote code execution — that is a separate class of problem — but they close off several of the easiest routes to a compromised account.
Strings, null bytes, and the end of silence
The second pillar of the release is a refusal to let bad input slip through quietly. The PHP engine is now much stricter when it encounters strings containing null bytes (\0). In many cases it throws an error instead of silently letting the value pass. This matters because null bytes are a favored trick for triggering RCE: a C function treats the null as the end of the string, processing everything before it and ignoring everything after — often with an attacker’s payload sitting in that ignored tail.
That “if you see something, say something” principle extends further. A number of functions that used to fail silently now report the failure explicitly:
fclose(),file_put_contents(), andcopy()now returnfalsewhen flushing or closing the stream fails, instead of ignoring the failure.- Many functions now throw a
ValueErrorfor out-of-range values, invalid flags, or strings containing NUL bytes, rather than silently truncating or discarding them. - Stream operations can be configured to throw a structured
StreamException, with errors reported asStreamErrorobjects carrying an error code, wrapper name, and affected path — retrievable later viastream_last_errors().
For developers, this is a double-edged sword. Failures that were once invisible now surface as exceptions and falsy returns — which is exactly what you want for data integrity, but only if your error handling is actually watching for them.
The deployment trap nobody asked for
Here is the part that is likely to catch administrators out. The new secure defaults only take effect if nothing else overrides them. As backend engineer Rajekevin Dourepoulle pointed out in a detailed write-up, an explicit setting in your application, framework, or another php.ini file will win every time.
In his words: “if your deployment reuses the old php.ini (an Ansible template, a COPY php.ini in a Dockerfile, a file copied from server to server), you move to 8.6 and gain nothing, because the explicit session.use_strict_mode = 0 line overrides the new default.”
In other words, upgrading the binary is not enough. If your configuration explicitly disables the old behaviors — and a great many production configs do — you must remove those lines to actually benefit from the new defaults. This is worth checking before you celebrate the upgrade:
; Remove or correct lines like these in your php.ini:
; session.use_strict_mode = 0 <- cancels the new default
; session.cookie_httponly = 0 <- cancels the new default
; session.cookie_samesite = "" <- cancels Lax
; Let PHP 8.6 defaults apply (or set them explicitly):
session.use_strict_mode = 1
session.cookie_httponly = 1
session.cookie_samesite = Lax
Beyond security: the features developers actually want
Security may be the theme, but 8.6 is a full feature release, and the language community is genuinely excited about a handful of additions.
Partial Function Application
Partial Function Application (PFA) is the headline feature. It lets you pre-fill some of a function's arguments using ? and ... placeholders, returning a reusable closure that accepts the rest. The function only runs once every argument is supplied. It is the kind of ergonomic improvement that has, as The Register put it, let PHP leapfrog JavaScript in this particular ability.
$versions = ['8.4', '8.5', '8.6', '8.7', '9.0'];
// PHP 8.5 and older: wrap in an arrow function
$supportsPfa = array_filter(
$versions,
fn ($version) => version_compare($version, '8.6', '>='),
);
// PHP 8.6: pre-fill the second argument with a placeholder
$supportsPfa = array_filter(
$versions,
version_compare(?, '8.6', '>='),
);
// Pre-configure any function into a reusable closure
$waitBeforeRetry = backoff(
Duration::fromSeconds(1),
Duration::fromMilliseconds(100),
attempt: ?,
);
$waitBeforeRetry($attempt);
A stopwatch you can measure in nanoseconds
The new \Time\Duration class represents elapsed time the way a stopwatch does — independent of any timezone, able to span more than 250 years with nanosecond precision. It is aimed squarely at timeouts and benchmark timings, and because durations are comparable, it works directly with functions like min() and the new clamp().
use Time\Duration;
$delay = Duration::fromSeconds(1)
->add(Duration::fromMilliseconds(100)->multiplyBy(2 ** $attempt));
// Durations compare directly — no magic numbers
$delay = min($delay, Duration::fromSeconds(30));
// clamp() keeps any comparable value inside a range
var_dump(clamp(110, 0, 100)); // int(100)
var_dump(clamp(
Duration::fromSeconds(30),
min: Duration::fromMinutes(1),
max: Duration::fromMinutes(10),
)->seconds); // int(60)
Polling built for real concurrency
The new Io\Poll API monitors many streams at once using the best native mechanism on each platform — epoll, kqueue, event ports, or WSAPoll. It sidesteps the scalability ceiling of stream_select(), which typically struggles past 1,024 connections, and is designed as a foundation for event-loop libraries such as ReactPHP and AMPHP.
The rest of the list
Rounding out the release:
- A type-safe
SortDirectionenum withAscendingandDescendingcases. - Readonly properties can now declare default values instead of requiring constructor assignment.
- Function parameters can carry their own DocComments, readable via
ReflectionParameter::getDocComment(). - Sodium gains post-quantum key encapsulation (X-Wing and ML-KEM-768), IP address encryption, and SHAKE / TurboSHAKE.
- TLS streams support session resumption, external pre-shared keys, and TLS 1.3 early data (0-RTT).
- Performance work includes compiling
array_map()with partial-application callbacks into loops, fasterprintf(), cached stateless closures, and faster JSON encoding.
What will break when you upgrade
A major release always carries deprecations, and 8.6 has a substantial list. These are worth scanning before you point production at the new binary:
← swipe to see all columns →
| Deprecated / changed | Use instead |
|---|---|
return inside finally | Restructure control flow — it silently discarded exceptions |
Returning a value from __construct() / __destruct() | Remove the return statement |
mb_ereg(), mb_split() and other mbstring regex functions | PCRE functions with the u modifier (Oniguruma is unmaintained) |
is_double(), is_long(), is_integer(), doubleval() | is_float(), is_int(), floatval() |
spl_object_hash(), spl_classes() | spl_object_id(), ReflectionExtension::getClassNames() |
Custom session handlers missing create_sid() / validateId() | Implement both methods |
trim() / ltrim() / rtrim() form-feed behavior | Now also strips \f by default |
Should you upgrade to PHP 8.6?
If you are already on a supported PHP version, the security argument is strong. The session defaults alone close off realistic attack paths that many applications never bothered to harden themselves, and the stricter error behavior turns silent corruption into visible, fixable problems. The coordinated patch release that accompanied 8.6 also closed seven critical RCE flaws across the supported branches, so staying current is not optional this cycle.
But go in with your eyes open. Audit your php.ini and framework config for explicit overrides of the three session settings, or you will gain none of the new defaults. Scan your codebase for the deprecated functions above. And make sure your error handling is prepared for functions that now return false or throw where they once stayed quiet.
For framework users — WordPress, Laravel, Symfony — the practical advice is the same as it has been all month: update, test on a staging environment, and then update production. The language is getting stricter. That is good news for security; it is a little less comfortable for anyone who grew used to PHP quietly looking the other way.
Frequently asked questions
When was PHP 8.6 released?
November 19, 2026, on PHP's annual release schedule.
What are the most important changes in PHP 8.6?
Secure-by-default session settings (Strict Mode, HttpOnly, SameSite=Lax), stricter handling of null bytes and stream failures, Partial Function Application, the Time\Duration class, a Polling API, and a new clamp() function.
Do the new session defaults apply automatically?
Only if nothing overrides them. Explicit settings in your application, framework, or another php.ini file take precedence — so an old session.use_strict_mode = 0 line will cancel out the new default.
Does PHP 8.6 fix the PHP2Shell vulnerabilities?
The coordinated release accompanying 8.6 closed seven critical RCE flaws across PHP 8.2 through 8.6. The stricter defaults make exploitation harder going forward, but they are not a substitute for patching.
What is Partial Function Application?
It lets you pre-fill some of a function's arguments with ? or ... placeholders, producing a reusable closure. The original function is only called once all arguments have been provided.
Is PHP 8.6 a safe upgrade for WordPress?
Generally yes, after testing. Check for explicit session-setting overrides in your configuration and for use of deprecated functions. Update on staging first, then production.
Conclusion
PHP 8.6 is not the most glamorous release the language has shipped, but it may be one of the more important. After a month in which remote code execution bugs dominated the headlines, the core team has chosen to tighten the defaults that let bad input and sloppy configuration slide. Stricter sessions, loud failures instead of silent ones, and a set of genuinely useful language features make this a solid upgrade — provided you do the configuration homework first.
The broader lesson is bigger than PHP. Defaults shape security more than most developers realize, and a language willing to change them — even at the cost of some backward compatibility — is doing its users a favor. PHP 8.6 is that kind of release. Just remember to check your php.ini.

Leave a Reply