What's New in PHP 8.5: A Comprehensive Overview

PHP 8.5 will be released in November 2025 and brings several useful new features and improvements. This version focuses on developer experience enhancements, new utility functions, and better debugging capabilities.
Key New Features at a Glance
1. New Array Functions: array_first()
and array_last()
PHP 8.5 adds two highly requested functions for retrieving the first and last values of an array, complementing the existing array_key_first()
and array_key_last()
functions from PHP 7.3.
$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)]
More details: PHP.Watch - array_first() and array_last()
2. Pipe Operator (|>
)
PHP 8.5 introduces a new pipe operator (|>
) that allows chaining multiple callables from left to right, passing the return value of the left callable to the right one:
$result = 'Hello World'
|> strtoupper(...)
|> str_shuffle(...)
|> trim(...);
// Output: 'LWHO LDLROE' (or similar shuffled result)
// Equivalent to nested calls:
$result = trim(str_shuffle(strtoupper('Hello World')));
// Or using variables:
$result = 'Hello World';
$result = strtoupper($result);
$result = str_shuffle($result);
$result = trim($result);
The pipe operator works with any callable - functions, methods, closures, and first-class callables. However, it has some limitations:
All callables must accept only one required parameter
Functions with by-reference parameters cannot be used (with few exceptions)
The return value is always passed as the first parameter
More details: PHP.Watch - Pipe Operator
3. New Error and Exception Handler Getters
PHP 8.5 introduces two new functions that allow you to retrieve the currently active error and exception handlers: get_error_handler()
and get_exception_handler()
.
This is particularly useful for:
Framework development and handler chaining
Debugging error handling configurations
Temporarily overriding handlers while preserving the original
Both functions return the current handler callable or null
if no custom handler is set.
More details: PHP.Watch - get_error_handler() and get_exception_handler()
4. New cURL Function: curl_multi_get_handles()
The cURL extension gets a new function for retrieving 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);
// New in PHP 8.5: Get all handles
$handles = curl_multi_get_handles($multiHandle);
// Returns: [$ch1, $ch2]
// Execute and process results
$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);
}
More details: PHP.Watch - curl_multi_get_handles()
5. New Locale Function: locale_is_right_to_left()
PHP 8.5 adds support for detecting right-to-left (RTL) locales, improving internationalization capabilities:
// Check if locale uses RTL writing
$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 approach
$isRTL = Locale::isRightToLeft('he_IL'); // true (Hebrew)
This is particularly useful for:
Building multilingual web applications
Proper text alignment in user interfaces
Dynamic CSS class assignment based on locale
More details: PHP.Watch - locale_is_right_to_left()
6. New PHP_BUILD_DATE
Constant
A new constant provides the build date of the PHP binary, useful for debugging and version auditing:
echo PHP_BUILD_DATE; // e.g., 'Nov 15 2025 10:30:45'
// Useful for debugging in production
echo 'PHP Version: ' . PHP_VERSION . "\n";
echo 'Build Date: ' . PHP_BUILD_DATE . "\n";
More details: PHP.Watch - PHP_BUILD_DATE
7. CLI Enhancement: php --ini=diff
A new CLI option to output only non-default INI directives:
# Show only modified settings
php --ini=diff
# Example output:
# memory_limit = 256M (default: 128M)
# max_execution_time = 60 (default: 30)
More details: PHP.Watch - CLI --ini=diff
Why Upgrade to PHP 8.5?
Enhanced Developer Experience: The new array functions eliminate common boilerplate code and make intentions clearer.
Better Debugging: The new handler getters provide better insight into application behavior.
Improved Tooling: The new CLI option and build date constant help with debugging and deployment tracking.
Future-Proofing: Stay current with the latest PHP features and security updates.
Conclusion
PHP 8.5 may not introduce groundbreaking language changes, but it delivers practical improvements that enhance daily development workflows. The new array functions address long-standing developer requests, while the pipe operator provides a cleaner way to chain function calls.
The upgrade from PHP 8.4 to 8.5 should be straightforward for most applications, with the new features providing immediate value without breaking existing code.
Upgrade Recommendation: If you're already using PHP 8.4, upgrading to PHP 8.5 is recommended. The new features improve code quality and debugging capabilities with minimal migration effort.