Discover PHP 8.5’s New Array, Pipe, and cURL Features for Faster Development

PHP 8.5, slated for release in November 2025, introduces handy array helpers, a left‑to‑right pipe operator, getters for error and exception handlers, a cURL multi‑handle retrieval function, RTL locale detection, a build‑date constant, and a CLI option to show only modified INI settings, all aimed at improving developer experience and debugging.

Open Source Tech Hub
Open Source Tech Hub
Open Source Tech Hub
Discover PHP 8.5’s New Array, Pipe, and cURL Features for Faster Development

New array functions: array_first() and array_last()

PHP 8.5 adds two high‑request functions that return the first and last values of an array, complementing the existing array_key_first() and array_key_last() utilities.

$users = ['Alice', 'Bob', 'Charlie'];
$firstUser = array_first($users); // 'Alice'
$lastUser  = array_last($users);  // 'Charlie'

// Works with associative arrays too
$data = ['name' => 'John', 'age' => 30, 'city' => 'Berlin'];
echo array_first($data); // 'John'
echo array_last($data);  // 'Berlin'

// Returns null for empty arrays
$empty = [];
var_dump(array_first($empty)); // null
var_dump(array_last($empty));  // null

These functions are equivalent to:

array_first($array) → $array[array_key_first($array)]
array_last($array) → $array[array_key_last($array)]

Pipe operator

PHP 8.5 introduces a new pipe operator |> that lets you chain callable objects left‑to‑right, passing the result of the left side as the first argument to the right side.

$result = 'Hello World'
    |> strtoupper(...)
    |> str_shuffle(...)
    |> trim(...);
// Output: a shuffled, upper‑cased, trimmed string

// Equivalent to nested calls
$result = trim(str_shuffle(strtoupper('Hello World')));

Limitations:

All callables must accept exactly one required parameter.

Functions with by‑reference parameters are not supported (few exceptions).

The return value is always passed as the first argument.

New error and exception handler getters

Two new functions, get_error_handler() and get_exception_handler(), return the currently active callable handlers, or null if no custom handler is set.

New cURL function: curl_multi_get_handles()

The cURL extension now provides a function to retrieve all handles from a multi‑handle.

$multiHandle = curl_multi_init();
$ch1 = curl_init('https://api.example.com/users');
$ch2 = curl_init('https://api.example.com/posts');
curl_multi_add_handle($multiHandle, $ch1);
curl_multi_add_handle($multiHandle, $ch2);

$handles = curl_multi_get_handles($multiHandle); // [$ch1, $ch2]

$running = null;
do {
    curl_multi_exec($multiHandle, $running);
} while ($running > 0);

foreach ($handles as $handle) {
    $response = curl_multi_getcontent($handle);
    curl_multi_remove_handle($multiHandle, $handle);
}

New locale function: locale_is_right_to_left()

This function detects whether a given locale uses right‑to‑left writing, improving internationalisation support.

$isRTL = locale_is_right_to_left('ar_SA'); // true (Arabic)
$isLTR = locale_is_right_to_left('en_US'); // false (English)
$isFarsi = locale_is_right_to_left('fa_IR'); // true (Persian/Farsi)

// Object‑oriented usage
$isRTL = Locale::isRightToLeft('he_IL'); // true (Hebrew)

New constant: PHP_BUILD_DATE

A constant exposing the build date of the PHP binary, useful for debugging and version audits.

echo PHP_BUILD_DATE; // e.g., 'Nov 15 2025 10:30:45'

echo 'PHP Version: ' . PHP_VERSION . "
";
echo 'Build Date: ' . PHP_BUILD_DATE . "
";

CLI enhancement: php --ini=diff

A new CLI option that outputs only non‑default INI directives, helping developers spot configuration changes.

# Show only modified settings
php --ini=diff

# Example output:
# memory_limit = 256M (default: 128M)
# max_execution_time = 60 (default: 30)
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.

CLIcurlarray functionsPipe OperatorlocalePHP 8.5
Open Source Tech Hub
Written by

Open Source Tech Hub

Sharing cutting-edge internet technologies and practical AI resources.

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.