PHP 8.5 has been officially released, introducing several significant enhancements geared towards improving web development with this popular open-source scripting language.
One of the major highlights of PHP 8.5 is the inclusion of a built-in URI extension, allowing developers to parse, normalize, and manage URLs in compliance with RFC 3986 and WHATWG URL standards. Another notable feature is the new Pipe |> operator, which facilitates the chaining of callables from left to right, enabling smoother value passing through multiple functions without the need for intermediary variables.
Additionally, PHP 8.5 introduces a new clone() syntax. This feature streamlines the process of cloning objects and modifying properties, particularly benefiting readonly classes. The #[NoDiscard] attribute has also been added, which issues a warning if a return value is not utilized, aiding in the prevention of common mistakes and enhancing API safety.
The update further includes a new curl_multi_get_handles function that supports persistent cURL share handles across multiple PHP requests, helping to eliminate the overhead associated with repeatedly initializing connections to the same hosts. It also introduces support for static closures and first-class callables in constant expressions, such as in attribute parameters.
Other notable changes in PHP 8.5 comprise stack trace support for PHP Fatal errors, a new max_memory_limit INI directive to set a ceiling on memory usage, and a new PHP_BUILD_DATE constant. The addition of an IntlListFormatter class and new functions like get_exception_handler and get_error_handler also contribute to a more robust development experience.
The new version adds utility functions such as array_first and array_last to retrieve the first or last value of an array, alongside a function for checking if a locale is right-to-left. A new command, php --ini=diff, has also been added to show non-default INI directives.
Developers can download PHP 8.5 from the official website as a source tarball, and it will soon be available in the stable repositories of various popular GNU/Linux distributions. Detailed changes can be reviewed in the release notes for this major update.
