What’s New in PHP 8.5? Pipe Operator, array_first/last, URI Extension & More

PHP 8.5, slated for release on November 20 2025, introduces a pipe operator, native array_first() and array_last() functions, a standards‑compliant URI extension, closure self‑reference retrieval, fatal error backtraces, and INI diff options, with code examples and a detailed release schedule.

21CTO
21CTO
21CTO
What’s New in PHP 8.5? Pipe Operator, array_first/last, URI Extension & More

Dear developers, PHP 8.5 is scheduled for release on November 20 2025. It will include a pipe operator, a new URI extension, native array_first() and array_last() functions, among other enhancements.

Pipe operator

Native array_first() and array_last() functions

New URI extension

Retrieving the currently executing closure

Fatal error backtraces

INI diff option

https://php.watch/versions/8.5/rfcs

Pipe Operator

For developers who want to chain multiple callable functions and pass values left‑to‑right, the pipe operator offers an exciting prospect.

// Using the pipe operator in PHP 8.5
$result = "Hello World"
    |> htmlentities(...)
    |> str_split(...)
    |> fn($x) => array_map(strtoupper(...), $x)
    |> fn($x) => array_filter($x, fn($v) => $v != 'O');

Native array_first() and array_last() Functions

PHP 8.5 introduces native array_first() and array_last() functions. Although user‑space polyfills exist, these functions have long deserved native support.

In PHP 7.3 we used array_key_first() and array_key_last() to obtain the first and last keys, but there was no way to get the first and last values directly.
// Function signatures
function array_first(array $array): mixed {}
function array_last(array $array): mixed {}

// Examples
array_first(["single element"]); // "single element"
array_last(["single element"]); // "single element"
array_first([]); // NULL
array_last([]); // NULL
array_first([1=>'a', 0=>'b', 3=>'c', 2=>'d']); // 'a'
array_last([1=>'a', 0=>'b', 3=>'c', 2=>'d']); // 'd'

$str = "hello";
array_first([&$str, false]); // "hello" (no ref)
array_last([false, &$str]); // "hello" (no ref)

New URI Extension

PHP 8.5 adds a standards‑compliant URI extension that implements both RFC 3986 and the WHATWG URL specification, always available as part of the standard library.

use Uri\Rfc3986\Uri;

$url = new Uri('HTTPS://thephp.foundation:443/sp%6Fnsor/');

$defaultPortForScheme = match ($url->getScheme()) {
    'http' => 80,
    'https' => 443,
    'ssh' => 22,
    default => null,
};

// Remove default ports from URLs.
if ($url->getPort() === $defaultPortForScheme) {
    $url = $url->withPort(null);
}

// Getters normalize the URL by default. The `Raw` variants return the input unchanged.
echo $url->toString(), PHP_EOL; // https://thephp.foundation/sponsor/
echo $url->toRawString(), PHP_EOL; // HTTPS://thephp.foundation/sp%6Fnsor/

Retrieving the Currently Executing Closure

PHP 8.5 adds Closure::getCurrent(), allowing a closure to obtain a reference to itself for recursive calls.

$fibonacci = function (int $n) {
    if (0 === $n || 1 === $n) {
        return $n;
    }
    $fn = Closure::getCurrent();
    return $fn($n - 1) + $fn($n - 2);
};

echo $fibonacci(10) . "
";

Fatal Error Backtraces

The new fatal_error_backtraces ini setting controls whether backtraces are shown for fatal errors. In PHP 8.5 the default is 1, so backtraces appear without additional configuration.

Fatal error: Cannot redeclare class B (previously declared in /srv/app/index.php:11) in /srv/app/b.php on line 3
Stack trace:
#0 /srv/app/index.php(6): require()
#1 /srv/app/index.php(21): A->loadClassB()
#2 {main}

INI Diff Option

PHP 8.5 adds an INI diff option to the php --ini command, making it easy to spot configuration changes.

$ php --ini=diff
Non-default INI settings:
allow_url_include: "0" -> ""
auto_append_file: (none) -> ""
auto_prepend_file: (none) -> ""
display_errors: "1" -> ""
display_startup_errors: "1" -> ""
enable_dl: "1" -> ""
error_reporting: (none) -> "22527"
...

Release Schedule

PHP 8.5 follows a typical release cadence: three alphas (Alpha 1 – Alpha 4, with Alpha 3 skipped), a feature freeze, three betas (Beta 1 – Beta 3), and four release candidates (RC 1 – RC 4) before the final GA release on 20 November 2025.

For the full list of RFCs, download the source, or check the deprecation list for early adopters.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Backend DevelopmentprogrammingPHPNew FeaturesPHP 8.5
21CTO
Written by

21CTO

21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.