The new PHP 8.5 version was officially released on 20 November 2025. This version introduces a set of exciting new features alongside some minor changes and deprecations. In this article we cover the most important changes to expect, so you can prepare for the next version of PHP.
New Features
Pipe Operator (|>)
One of the most anticipated features in PHP 8.5 is the introduction of the pipe operator (|>). It allows multiple functions to be executed sequentially, with the return value of the previous one being passed as the first argument of the next. While it does not introduce new language capabilities, the operator can significantly improve code readability.
$result = "Hello World"
|> strtoupper(...)
|> str_shuffle(...)
|> trim(...);
// Example output: "LWHO LDLROE" (will vary due to str_shuffle)
// This is the same as:
$result = trim(str_shuffle(strtoupper("Hello World")));
The pipe operator works with any callable (user functions, built-in functions, static methods, closures, etc.), but requires each callable in the chain to accept exactly one parameter.
New INI Directive: max_memory_limit
PHP 8.5 introduces a new INI directive max_memory_limit, which allows you to set an upper bound for the memory_limit directive. This provides an additional layer of control — for example in shared hosting, where memory_limit may be set by individual applications, but a maximum system-wide cap is desirable. Since max_memory_limit is an INI_SYSTEM directive, it cannot be changed by code.
New Functions: array_first and array_last
Building on the array functions introduced in PHP 8.4, PHP 8.5 adds array_first() and array_last(), providing convenient ways to retrieve the first or last element of an array:
$myArray = [10, 20, 30, 40];
echo array_first($myArray); // Outputs: 10
echo array_last($myArray); // Outputs: 40
Stack Trace Support for Fatal PHP Errors
Debugging fatal PHP errors can be challenging due to the lack of detailed information. PHP 8.5 addresses this by adding stack trace support for fatal PHP errors. When such an error occurs, a comprehensive stack trace will now be provided to help locate the root cause.
New Functions: get_exception_handler and get_error_handler
These new functions allow retrieving the currently registered exception and error handlers, making it easier to manage and debug custom error handling logic.
New Constant: PHP_BUILD_DATE
A new PHP_BUILD_DATE constant exposes the date on which the PHP binary was compiled, useful for debugging and version management.
CLI: php --ini=diff
A new CLI option --ini=diff outputs only INI directives that differ from their default values, making it easier to spot custom configuration changes.
Intl: New IntlListFormatter Class
The new IntlListFormatter class provides locale-aware list formatting (e.g., "apples, oranges, and bananas"), wrapping the ICU ListFormatter functionality.
Curl: New curl_multi_get_handles Function
The new curl_multi_get_handles() function returns an array of cURL handles attached to a multi handle, simplifying inspection of multi-request operations.
New Functions: locale_is_right_to_left and Locale::isRightToLeft
These new functions check whether a given locale is right-to-left, useful for building internationalised applications.
Deprecations
- All
MHASH_*constants are deprecated; - Non-canonical scalar type coercions (
boolean|double|integer|binary) are deprecated; - Returning non-string values from User Output Handlers is deprecated;
- Outputting content from User Output Handlers is deprecated.
Conclusion
PHP 8.5 brings practical improvements across readability, debugging and internationalisation. The pipe operator in particular is a long-awaited addition that will clean up deeply nested function calls. If you plan to upgrade, review the deprecations to ensure your codebase is compatible.