- 0 -

PHP 8.5 What's news in this version ?

PHP 8.5 is scheduled for release in November 2025. It comes with several helpful new features and improvements, focusing on a better developer experience, new utility functions, and enhanced debugging capabilities.

question What is news ?

1) The pipe operator |>:

This new operator enables chaining of callables left-to-right by passing the result of the left expression as the argument to the right:

$result = "Hello World" |> strlen(...) 
  
// Equivalent to 
$result = strlen("Hello World");


$result = 'Hello World'
    |> strtoupper(...)
    |> str_shuffle(...)
    |> trim(...);
// Equivalent to: trim(str_shuffle(strtoupper('Hello World')));

2) New array functions: array_first() and array_last():

PHP 8.5 introduces two much-requested functions to fetch the first and last values of an array, complementing PHP 7.3’s array_key_first() and array_key_last().

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

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

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

3) New cURL function: curl_multi_get_handles():

Enables retrieving all handles associated with 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]

4) Getters for error and exception handlers:

PHP 8.5 adds get_error_handler() and get_exception_handler() to retrieve the currently active handlers—useful for framework development, chaining handlers, or temporary replacements while preserving the originals. They return the current callable or null if none is set.

5) New PHP_BUILD_DATE constant:

Outputs the PHP build date — useful for debugging and audit trails:

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

6) Locale support: locale_is_right_to_left():

Helps detect if a given locale is right-to-left (RTL), with an object-oriented alternative via Locale::isRightToLeft():

$isRTL = locale_is_right_to_left('ar_SA'); // true (Arabic)
$isLTR = locale_is_right_to_left('en_US'); // false (English)
$isRTL = Locale::isRightToLeft('he_IL');   // true (Hebrew)

7) CLI improvement: php --ini=diff:

Shows only non-default INI directives:

php --ini=diff
# Example output:
# memory_limit = 256M (default: 128M)
# max_execution_time = 60 (default: 30)

0 Comment(s)

Information

There are no comments yet, post the first reply !

Information

You need to be logged in to comment to this article !