PHP 8.5 Introduces Pipe Operator and Standards-Compliant URI Tools
PHP 8.5, released on Thursday, features two major updates: the long-awaited pipe operator and a new standards-compliant URI parser. The pipe operator enables developers to chain function calls, reducing the need for extraneous variables and nested statements. This feature, which is familiar to users of Unix/Linux command lines and languages like R, F#, Clojure, and Elixir, enhances code readability and streamlines operations that previously required more verbose coding practices.
The URI parser, now aligned with RFC 3986 and WHATWG standards, addresses a longstanding gap in PHP’s standard library. Previously, developers had to rely on the parse_url() function from PHP 4, which lacked compliance with modern standards and carried a warning against its use with untrusted or malformed URLs. The new URI extension provides a robust solution for parsing and modifying URIs and URLs, which is a common task in web-oriented applications.
Other notable updates in PHP 8.5 include the Clone With feature, which allows for more efficient property updates during object cloning. Developers can also utilize the #[
NoDiscard] attribute to receive warnings when return values are unused, improving code quality and maintainability. Additional enhancements include the ability to use static closures and first-class callables in constant expressions, offering greater flexibility in coding practices. Finally, persistent cURL handles are now supported, enabling the sharing of handles across multiple PHP requests, which can improve performance in high-traffic environments.
The release of PHP 8.5 marks a significant step forward for the scripting language, addressing long-standing issues and introducing features that align with modern development practices. These updates are expected to enhance developer productivity and improve the reliability of web applications built on PHP.