PHP, one of the foundational languages of the web, keeps evolving. The release of PHP 8.5 on November 20, 2025 confirms that the language still wants to be relevant in a world of modern APIs, microservices and high-performance applications.
This version is not just a small incremental patch: it introduces a new URI extension, the pipe operator |>, improvements to object cloning, new array helpers and several changes in security and debugging that will affect day-to-day work for development teams.
URI extension: treating URLs as first-class citizens
Until PHP 8.4, working with URLs in a robust way meant combining functions like parse_url() with custom utilities or third-party libraries. PHP 8.5 finally ships with a built-in URI extension, always available, that lets developers:
- Parse, normalize and modify URLs consistently
- Follow the RFC 3986 and WHATWG URL standards
- Rely on well-known libraries like uriparser (for RFC 3986) and Lexbor (for WHATWG)
Instead of returning arrays and forcing developers to access indices manually, PHP now allows working with objects in namespaces such as Uri\Rfc3986\Uri and methods like getHost(). That reduces subtle bugs in applications dealing with redirects, URL signatures, microservices or system integrations.
Pipe operator |>: more readable and maintainable code
Another big highlight in PHP 8.5 is the pipe operator |>, designed to chain calls from left to right, without temporary variables and without deeply nested expressions.
Previously, code often looked like this:
$title = ' PHP 8.5 Released ';
$slug = strtolower(
str_replace('.', '',
str_replace(' ', '-',
trim($title)
)
)
);
Code language: PHP (php)
With PHP 8.5 that can be rewritten in a much clearer way:
$title = ' PHP 8.5 Released ';
$slug = $title
|> trim(...)
|> (fn($str) => str_replace(' ', '-', $str))
|> (fn($str) => str_replace('.', '', $str))
|> strtolower(...);
Code language: PHP (php)
This style:
- Makes the code read in the same order as the data transformations
- Avoids the “Russian doll” pattern of nested function calls
- Encourages function composition, especially in complex data pipelines or reusable libraries
For projects with lots of business logic, data normalization or text processing, the pipe operator can be a real readability upgrade.
Clone With: safer, more convenient object cloning
PHP 8.5 introduces a key improvement for immutable patterns and readonly classes: the ability to change properties while cloning by passing an associative array to clone().
Instead of manually rebuilding the object with get_object_vars() and reconstructing it, developers can write:
readonly class Color
{
public function __construct(
public int $red,
public int $green,
public int $blue,
public int $alpha = 255,
) {}
public function withAlpha(int $alpha): self
{
return clone($this, [
'alpha' => $alpha,
]);
}
}
Code language: PHP (php)
This simplifies:
- Implementing immutable “with-er” patterns
- Creating new instances from existing objects by changing only a subset of properties
- Maintaining code in complex domains where immutability is a tool for safety and clarity
#[\NoDiscard]: avoiding silent mistakes
The new #[\NoDiscard] attribute lets developers mark functions whose return value should not be ignored. If code calls such a function and the return value is not used, PHP 8.5 will emit a warning.
This is especially useful for:
- Functions that return critical results (state, configuration objects, validation results, etc.)
- APIs where it is easy to call a function but forget to use its result, causing subtle logical bugs
If the value is intentionally ignored, the (void) cast can be used to signal that intent and silence the warning.
More expressive constants, attributes and functions
PHP 8.5 also allows static closures and first-class callables in constant expressions, including:
- Attribute parameters
- Default values for properties and parameters
- Class constants
This opens the door to more expressive definitions in areas like access control, validation or routing, without relying on “magic strings” that are only evaluated at runtime.
Faster networking: persistent cURL share handles
On the performance front, one of the most relevant additions is support for persistent cURL share handles via curl_share_init_persistent().
Instead of destroying shared handles at the end of each request, PHP 8.5 can:
- Reuse connections and share handles across multiple requests that use the same set of options
- Avoid the repeated overhead of initializing cURL connections to the same hosts
- Improve performance in applications that make many HTTP requests (APIs, microservices, third-party integrations)
In backends with high traffic and lots of outgoing calls, this can translate into lower response times and more efficient resource usage.
Small, very practical improvements: arrays, memory, traces and more
Beyond the headline features, PHP 8.5 brings a set of “quality-of-life” improvements:
- New
array_first()andarray_last()functions, which return the first or last value of an array (ornullif the array is empty) - Stack traces for fatal errors, such as exceeded maximum execution time, making debugging far easier
- A new INI directive
max_memory_limitthat lets administrators set an upper memory ceiling above the typicalmemory_limit - New
get_error_handler()andget_exception_handler()functions to inspect currently registered handlers - New internationalization helpers like
locale_is_right_to_left()andLocale::isRightToLeft, especially useful for interfaces that must adapt to right-to-left languages
All of this reduces the need for custom helper functions and makes the language more comfortable and safer by default.
Deprecations and breaking changes to watch closely
As with every major release, PHP 8.5 also brings deprecations and potential backward-compatibility breaks:
- The backtick operator as an alias for
shell_exec()is now deprecated - Non-canonical cast names like
(boolean)or(integer)are deprecated in favor of(bool)and(int) - New warnings are emitted in ambiguous situations, such as casting certain
floatvalues tointor usingnullas an array index - The magic methods
__sleep()and__wakeup()are soft-deprecated in favor of__serialize()and__unserialize()
Before upgrading large, complex projects, it is essential to review the official migration guide and test thoroughly in staging environments.
Compatibility table: what PHP 8.5 adds over previous versions
The table below summarizes, in a simplified way, the availability of some key features in the latest PHP 8.x releases.
“Sí” means the feature is present; “No” means it is not available in that version (or behaves significantly differently).
| Feature / change | PHP 8.1 | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|---|
| Built-in URI extension (RFC 3986 / WHATWG URL) | No | No | No | No | Sí |
| Pipe operator `>` for chaining calls | No | No | No | No | Sí |
clone($obj, [...]) “Clone With” syntax | No | No | No | No | Sí |
#[\NoDiscard] attribute | No | No | No | No | Sí |
| Closures / first-class callables in constant expressions | No | No | No | No | Sí |
curl_share_init_persistent() (persistent cURL share handle) | No | No | No | No | Sí |
array_first() and array_last() | No | No | No | No | Sí |
| Stack traces for fatal errors | No | No | No | No | Sí |
max_memory_limit INI directive | No | No | No | No | Sí |
Deprecation of backtick operator as shell_exec() alias | No | No | No | No | Sí |
This is not an exhaustive change log, but it makes one point very clear: most of the big improvements in readability, safety, networking performance and URL handling land for the first time in PHP 8.5. For many teams, that will be a strong incentive to start planning an upgrade path as soon as their frameworks and libraries support it.
PHP 8.5 shows that the language is not content with merely preserving historical compatibility. It is moving steadily toward cleaner syntax, safer APIs and a technical foundation that’s better prepared for the modern web. For developers running PHP in production every day, this release is a clear invitation to start testing, measuring and, when the ecosystem is ready, making the jump.
