PHP 8.6

PHP 8.6: New Features, WordPress Compatibility & How to Upgrade (2026)

PHP 8.6 was released on November 19, 2026, as the latest major version of the language. It adds partial function application, a new clamp() function, a Duration class and a native polling API. It also deprecates several old functions that many WordPress plugins still use.

In this guide, we cover what is new, what breaks, and how WordPress 7.2 handles the new version. Then we walk through a safe way to upgrade your sites without surprises.

What’s New in PHP 8.6?

According to the official release announcement, this is a major update focused on more expressive code, stronger types and scalable I/O. Here are the features that matter most for everyday web development.

Partial function application

This is the headline feature. You can now pass some arguments to a function in advance and use ? as a placeholder for the rest. The result is a closure, so the function only runs once you supply the missing values.

In practice, this replaces many short arrow functions. For example, filtering version numbers becomes much cleaner:

$versions = ['8.4', '8.5', '8.6', '8.7'];

// Before: an arrow function
$modern = array_filter($versions, fn ($v) => version_compare($v, '8.6', '>='));

// New: partial function application
$modern = array_filter($versions, version_compare(?, '8.6', '>='));

The new clamp() function

Developers have written max(0, min($value, 100)) for years. Now there is a dedicated function for it. In addition, clamp() works with any comparable value, not just numbers.

clamp(110, 0, 100); // int(100)
clamp(-10, 0, 100); // int(0)
clamp(50, 0, 100);  // int(50)

Duration, polling and stream errors

The release also adds several lower-level tools. These are useful for libraries, queues and long-running workers:

  • \Time\Duration represents elapsed time with nanosecond precision, which is ideal for timeouts and retry delays.
  • Io\Poll is a native polling API. It uses epoll, kqueue, event ports or WSAPoll, so event loops like ReactPHP and AMPHP can scale past stream_select().
  • Stream error handling lets stream functions throw a StreamException instead of emitting warnings you have to silence with @.

Smaller quality-of-life features

  • A built-in SortDirection enum with Ascending and Descending cases.
  • Readonly properties can now declare default values, so you no longer need a constructor just to set them.
  • Function parameters can have their own DocComments, readable through Reflection.
  • JSON error messages now include the location of the error in the input.

Deprecations and Breaking Changes to Check

New features are exciting, but deprecations are where real sites break. Therefore, review this list before you switch any production server.

  • spl_object_hash() is deprecated in favour of spl_object_id().
  • is_double(), is_long(), is_integer() and doubleval() are deprecated aliases.
  • Using return inside a finally block now triggers a deprecation.
  • The mbstring regex functions, such as mb_ereg() and mb_split(), are deprecated.
  • Sessions are stricter by default: session.use_strict_mode and session.cookie_httponly are on, and session.cookie_samesite is Lax.
  • fclose(), file_put_contents() and copy() now return false when flushing or closing a stream fails.

Most of these are deprecations, not removals. In other words, your code keeps running, but you will see notices in your logs. However, the session defaults and the stream return values are real behaviour changes, so test them carefully.

Is WordPress Ready for PHP 8.6?

Yes, with a few caveats. The WordPress and PHP 8.6 dev note confirms that WordPress 7.2 is fully compatible with PHP 8.6 as of Beta 5. Moreover, all known compatibility issues in WordPress core have been fixed.

WordPress 7.2 is scheduled for December 8, 2026. It does not change the minimum supported PHP version, which stays at 7.4. If you have not looked at the release yet, read our WordPress 7.2 Beta guide first.

What changed in WordPress core

The core team had to adjust a few areas for the new runtime. These changes are worth knowing if you build plugins or themes:

  • TrueType fonts: PHP now reports .ttf files as font/ttf instead of font/sfnt. WordPress accepts both, but your own MIME checks should too.
  • Custom stream wrappers: a wrapper without a stream_flush() method now fails on save. If your plugin registers one, add that method and return true.
  • GD image flips: core now uses imageflip(), because the old negative-dimension trick produces a black image on the new version.

The spl_object_hash() problem in plugins

This is the change most likely to fill your error log. The WordPress team found nearly 9,000 uses of spl_object_hash() across more than 2,300 plugins. As a result, many sites will see deprecation notices after switching to PHP 8.6.

The fix is simple, but watch the return type. spl_object_id() returns an integer rather than a 32-character string:

// Before (now deprecated)
$key = spl_object_hash($callback);

// After
$key = spl_object_id($callback); // returns an int

Also note that WordPress has shipped a clamp() polyfill since version 7.1. So you can use clamp() in plugins today, even on older PHP versions.

How to Upgrade to PHP 8.6 Safely

Never switch PHP versions directly on a live store or membership site. Instead, follow a short, repeatable process.

  • Step 1: Make a copy. Clone the site to staging or your local machine. Our WordPress Reprint guide shows one way to do this.
  • Step 2: Update everything. Update WordPress core, your theme and every plugin first. Many authors release compatibility fixes quickly.
  • Step 3: Turn on logging. Set WP_DEBUG and WP_DEBUG_LOG to true, and keep WP_DEBUG_DISPLAY off.
  • Step 4: Switch PHP. Change the PHP version in your hosting panel for the staging site only.
  • Step 5: Test real journeys. Log in, check out, submit forms, upload images and run any cron tasks.
  • Step 6: Read the log. Open wp-content/debug.log and group notices by plugin. Then report problems to each author.

Here is the logging setup for wp-config.php:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

If you contribute to core or test locally with wordpress-develop, there is also an 8.6-fpm Docker image. Set LOCAL_PHP=8.6-fpm and restart the environment to use it.

When should you switch production?

For most business sites, wait until WordPress 7.2 is out and your key plugins confirm support. That gives the ecosystem a few weeks to catch up. Meanwhile, start testing now so nothing surprises you later.

Finally, keep PHP upgrades in your regular maintenance plan. Each release brings speed and security fixes, which is why we also recommend reviewing our guide to the best WordPress security plugins.

FAQ

When was PHP 8.6 released?

PHP 8.6 was released on November 19, 2026.

Does WordPress support PHP 8.6?

Yes. WordPress 7.2 is fully compatible with it as of Beta 5. However, individual plugins and themes may still trigger deprecation notices.

Will PHP 8.6 break my site?

Usually not, because most changes are deprecations. Still, stricter session defaults and stream return values can change behaviour, so always test on staging first.

What replaces spl_object_hash()?

Use spl_object_id(). Remember that it returns an integer, so update any code that stores or compares the old string value.

Conclusion

PHP 8.6 makes PHP code shorter and safer, thanks to partial function application, clamp() and better stream errors. At the same time, deprecations like spl_object_hash() mean plugin developers have work to do.

The good news is that WordPress 7.2 is ready. So clone your site, switch to PHP 8.6 on staging, read the logs, and fix issues before your host makes the change for you.

Sources

Need Help With Your Website or Web App?

Swrice builds and customises WordPress sites, plugins and web apps. Whether you need an upgrade, a custom feature or a fix, our team can handle it for you.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *