The PHP development team has announced the release of PHP 8.6, the latest major update to the widely used server-side scripting language.
One headline addition is partial function application, which allows developers to provide some arguments to a function in advance and receive a closure that accepts the remaining ones. Using ? and ... placeholders, this feature reduces the need to write separate anonymous functions when working with callbacks and higher-order functions.
Another improvement is the new Io\Poll API, designed to handle many simultaneous I/O operations more efficiently. It uses native operating system mechanisms, including Linux’s epoll, BSD’s kqueue, and Windows’ WSAPoll, overcoming scalability limitations of the existing stream_select() function.
PHP 8.6 also introduces the Time\Duration class for representing elapsed time independently of dates and time zones. Supporting nanosecond precision and durations over 250 years, it gives a more convenient way to manage timeouts, retry delays, and benchmarking.
On the language side, developers gain a new clamp() function that restricts values to a specified minimum and maximum, along with a built-in SortDirection enum providing standardized ascending and descending sorting options.
Moreover, readonly properties can now declare default values directly, eliminating the need for constructor assignments when the value is fixed. Reflection capabilities have also been extended with new methods to check whether properties are readable or writable, plus support for documentation comments on individual function parameters.
Stream error handling also improves, with applications now able to configure stream operations to throw StreamException exceptions instead of emitting warnings, with structured error information available through StreamError objects. This makes diagnosing file and network I/O failures easier.
On the security side, PHP 8.6 enables strict session mode and HttpOnly session cookies by default and sets the default SameSite cookie policy to Lax.
Performance improvements include faster JSON encoding and printf() operations, caching of stateless closures, and optimizations that compile certain array_map() calls into more efficient loops. JSON parsing errors now identify the location of the problem in the input, making malformed data easier to troubleshoot.
Finally, PHP 8.6 introduces several deprecations developers should consider before upgrading. These include the mb_ereg() and mb_split() regular expression functions, spl_object_hash(), and older type-checking aliases such as is_integer() and is_double().
For more information, refer to the official PHP 8.6 release announcement.
