PHP 8.5 Adds URI Extension
Written by Kay Ewbank   
Friday, 12 December 2025

PHP 8.5 has been released with an extension supporting secure URI and URL parsing, a new a pipe operator and persistent cURL handles. 

PHP began life as a simple scripting language designed to build web pages but has developed into a general server side web language . It is now used for eight out of ten websites using server-side code. 

phplogo

The first improvement is a new always-available URI extension that provides APIs to Closures and First-Class Callables in Constant Expressions. The extension means that static closures and first-class callables can now be used in constant expressions. This includes attribute parameters, default values of properties and parameters, and constants. The addition allows developers to securely parse and modify URIs and URLs according to the RFC 3986 and the WHATWG URL standards.

Despite the importance of correctly parsing URLs, PHP hasn't until now included any standards-compliant parser within the standard library. There is the parse_url function, but it does not follow any standard and is explicitly documented not to be used with untrusted or malformed URLs. Developers have used this in place of any better alternative that is readily available, but while it works reasonably correctly for a majority of well-formed inputs that developers encounter in day-to-day work, it can still fail.  

The new extension provides standards-compliant parsers for both RFC 3986 and the WHATWG URL standard as an always-available part of its standard library. The PHP team says that not only will this enable easy, correct, and secure parsing of URLs according to the respective standard, but the URI extension also includes functionality to modify individual components of a URL.

The second addition is a NoDiscard attribute, which when added to a function means that PHP will check whether the returned value is consumed and emit a warning if it is not. This allows improving the safety of APIs where the returned value is important, but it's easy to forget using the return value by accident.

PHP now finally has a Pipe operator, so allowing the chaining of function calls together without dealing with intermediary variables. This enables replacing many "nested calls" with a chain that can be read forwards, rather than inside-out.

A new "Clone With" fproperty means developers can now update properties during object cloning by passing an associative array to the clone() function. This enables straightforward support of the "with-er" pattern for readonly classes.

Another improvement means that cURL share handles are now persistent. This means that unlike curl_share_init(), handles created by curl_share_init_persistent() will not be destroyed at the end of the PHP request. If a persistent share handle with the same set of share options is found, it will be reused, avoiding the cost of initializing cURL handles each time.

The final improvement of not is the addition of array_first() and array_last() functions. These return the first or last value of an array, respectively. If the array is empty, null is returned (making it easy to compose with the ?? operator). 

PHP 8.5 is available for download now.

phplogo

More Information

PHP Website

Related Articles

PHP 8.4 Adds Property Hooks

Is PHP in Trouble?

PHP 8.3 Released

Updated For PHP 8.3

PHP Adds Read-Only Classes

PHP - Essential But Underappreciated

Ten Minutes to PHP

PHP Is Best?

PHP 8.0 Adds Metadata To Classes

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Facebook or Linkedin.

Banner


Docker Releases Hardened Images For Free - What Does It Do Differently?
08/01/2026

Yet another provider jumps on the hardened image bandwagon. But since it's Docker, the main player in the container space, this is very important.



GSoC Offers Opportunities For Open Source Engagement
13/01/2026

It may be the depths of winter, but now is the time for Open Source organizations to be preparing their applications for Google Summer of Code. After a record-breaking year in 2025, Google is hop [ ... ]


More News

pico book

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Sunday, 14 December 2025 )