1 min read
|
Saved February 14, 2026
|
Copied!
Do you care about this?
PHP 8.5.0 introduces a new operator "|>" that allows for a more streamlined way to apply functions to values. It also adds the "#[\NoDiscard]" attribute to enforce the use of return values and introduces attributes for constants. Check the migration guide for more details on these changes.
If you do, here's more
PHP 8.5.0 has been released, introducing several notable features and changes. One of the most significant additions is the new pipe operator "|>", which allows for a more streamlined way to pass values into functions. For example, the expression `$result = "Hello world" |> strlen(...);` now achieves the same outcome as the traditional `$result = strlen("Hello world");`. This operator simplifies function calls and enhances code readability.
Another important feature is the introduction of the function attribute "#[\NoDiscard]". This attribute signals that the return value of a function should be utilized, potentially reducing bugs that arise from ignoring the output. PHP 8.5.0 also brings attributes to constants, expanding the ways developers can annotate and document their code.
For those upgrading from earlier versions, the migration guide provides detailed information on how to adapt to the new features. These updates aim to improve developer experience and code quality, reflecting PHP's ongoing evolution as a programming language.
Questions about this article
No questions yet.