PHP 8.5: New Features and Exciting Changes You Need to Know
14:44, 20.11.2025
PHP 8.5 has just been released, bringing new features and some compatibility-breaking changes. If you’re a PHP developer, this update is something you won’t want to miss. Let’s take a closer look at the new tools and improvements in this version.
Pipe Operator: Streamlining Your Code
One of the most anticipated additions is the new pipe operator (|>). This allows you to pass values directly from one function to another without the need for intermediate variables or assignments. If you’ve ever wanted cleaner and more readable code, this feature is a game-changer. The pipe operator makes it easy to chain functions, enhancing your workflow by passing output directly into the next function. If a function takes a single argument, you can use the ...syntax to pass values directly. For functions with multiple arguments, closures help you manage how values are assigned.
New Attributes and Enhancements for Better Code Control
PHP 8.5 introduces the #[NoDiscard] attribute, ensuring that the return values of certain functions are always used. If a value is ignored, you’ll get a warning, which can help prevent unexpected issues in your code. Additionally, you can now use closures and first-class callables in constant expressions—this was not allowed in earlier versions. Marking these closures as static ensures that they don’t reference external variables, keeping your code more predictable and manageable.
Modernizing the PHP Ecosystem
Other updates include useful functions like array_first() and array_last() for easily accessing the first and last elements of an array. The addition of a URI module simplifies URL parsing, and the Exif module now supports HEIF and HEIC image formats. These changes, along with other minor improvements, bring PHP closer to modern web development needs.
As you explore PHP 8.5, keep in mind that several outdated features have been deprecated. The removal of support for certain syntax and functions will push developers to adopt cleaner, more efficient coding practices. This release is another step forward for PHP, making it a more powerful and flexible language for your projects.