The PHP community is eagerly awaiting the launch of the next major version: PHP 8.5. This version promises to not only bring improvements in performance but also introduce a variety of new features—ranging from small but convenient additions to more profound changes in the core library. This article will provide an overview of the anticipated release date and explore some of the most exciting new features in PHP 8.5.
PHP 8.5 Release Date
According to the official development roadmap, PHP 8.5 is expected to be officially released on November 20, 2025. This marks an important milestone in the continuous development of the popular web programming language. We can look forward to the many improvements and utilities PHP 8.5 will bring.
Exploring the Notable New Features in PHP 8.5
PHP 8.5 introduces a range of new features focused on improving performance, enhancing the developer experience, and expanding the language’s capabilities. Below are some of the key features PHP 8.5 brings:
1. curl_multi_get_handles(): Retrieve List of cURL Handles in Multi Handle
PHP’s cURL library allows making HTTP requests and other network protocols. The curl_multi_* functions enable performing multiple cURL requests in parallel. PHP 8.5 introduces the curl_multi_get_handles() function, which lets you retrieve the list of all cURL handles currently managed by a cURL multi-handle.
Explanation: Previously, tracking cURL handles in a multi-handle setup could be complex. This new function provides a more intuitive and straightforward way to access and manage these handles, making it easier to monitor and control concurrent cURL processes.
Example:
<?php
$mh = curl_multi_init();
$handles = [];
$handles[] = curl_init("https://example.com/api/resource1");
$handles[] = curl_init("https://example.org/api/resource2");
foreach ($handles as $ch) {
curl_multi_add_handle($mh, $ch);
}
// Execute parallel requests
do {
$status = curl_multi_exec($mh, $active);
if ($active) {
curl_multi_select($mh);
}
} while ($active && $status == CURLM_OK);
// Get the list of handles
$currentHandles = curl_multi_get_handles($mh);
print_r($currentHandles);
// Close the handles and multi-handle
foreach ($handles as $ch) {
curl_multi_remove_handle($mh, $ch);
curl_close($ch);
}
curl_multi_close($mh);
?>2. New PHP_BUILD_DATE Constant
PHP 8.5 introduces a new constant called PHP_BUILD_DATE, which contains information about the date and time when the current PHP version was built.
Explanation: This constant provides an easy way to pinpoint the exact time the PHP version running was compiled. This can be useful for tracking, debugging, and ensuring consistency in deployment environments.
Example:
<?php
echo "PHP Version: " . PHP_VERSION . "\n";
echo "PHP Build Date: " . PHP_BUILD_DATE . "\n";
?>3. New Functions: get_exception_handler() and get_error_handler()
PHP 8.5 introduces two new functions: get_exception_handler() and get_error_handler(). These functions allow you to retrieve the currently set handlers for exceptions and errors, respectively, which were previously only set using set_exception_handler() and set_error_handler().
Explanation: Before, there was no direct way to retrieve the set handlers. These new functions provide greater flexibility for checking or restoring previous handlers when necessary, allowing better control over exception and error handling in your application.
Example:
<?php
function customExceptionHandler($exception) {
echo "An exception occurred: " . $exception->getMessage() . "\n";
}
function customErrorHandler($errno, $errstr, $errfile, $errline) {
echo "Error [$errno] $errstr at $errfile:$errline\n";
return true; // Prevent default PHP error handler
}
// Set custom handlers
set_exception_handler('customExceptionHandler');
set_error_handler('customErrorHandler');
// Retrieve current handlers
$currentExceptionHandler = get_exception_handler();
$currentErrorHandler = get_error_handler();
echo "Current Exception Handler: ";
var_dump($currentExceptionHandler);
echo "Current Error Handler: ";
var_dump($currentErrorHandler);
// Trigger error and exception to test
trigger_error("This is a test error.", E_USER_WARNING);
throw new Exception("This is a test exception.");
?>4. Support for Stack Trace in Fatal Errors
One of the valuable improvements in PHP 8.5 is the addition of support for stack traces in fatal errors.
Explanation: Fatal errors usually cause PHP scripts to stop immediately without providing much debugging information. With this update, when a fatal error occurs, PHP will provide a detailed stack trace, helping developers pinpoint exactly where and how the error happened, making the debugging process much easier.
Example:
<?php
function functionA() {
functionB();
}
function functionB() {
undefinedFunction(); // Fatal Error: Call to undefined function undefinedFunction()
}
functionA();
?>In PHP 8.5, running the code above will display a Fatal Error message along with a stack trace showing that the error occurred in functionB(), which was called by functionA().
5. New Functions: locale_is_right_to_left() and Locale::isRightToLeft()
PHP 8.5 introduces the locale_is_right_to_left() function and the static method Locale::isRightToLeft() in the Locale class of the Internationalization (intl) extension. These functions are used to check if a given locale (e.g., 'ar' for Arabic) is a right-to-left (RTL) language.
Explanation: This feature makes it easier for developers to determine the writing direction of specific languages, which is crucial for building multilingual applications that support RTL languages like Arabic, Hebrew, and others.
Example:
<?php
if (extension_loaded('intl')) {
$arabicLocale = 'ar';
$englishLocale = 'en';
if (locale_is_right_to_left($arabicLocale)) {
echo "$arabicLocale is a right-to-left language.\n";
} else {
echo "$arabicLocale is not a right-to-left language.\n";
}
if (Locale::isRightToLeft($englishLocale)) {
echo "$englishLocale is a right-to-left language.\n";
} else {
echo "$englishLocale is not a right-to-left language.\n";
}
} else {
echo "The intl extension is not installed.\n";
}
?>6. New Functions: array_first() and array_last()
PHP 8.5 introduces two new functions for working with arrays: array_first() and array_last().
Explanation: Previously, retrieving the first or last element of an array required using functions like reset() and end(). The new functions simplify these common operations.
Example:
<?php
$numbers = [1, 2, 3, 4, 5];
$first = array_first($numbers);
$last = array_last($numbers);
echo "First element: " . $first . "\n"; // Output: 1
echo "Last element: " . $last . "\n"; // Output: 5
$emptyArray = [];
$firstEmpty = array_first($emptyArray);
$lastEmpty = array_last($emptyArray);
var_dump($firstEmpty); // Output: null
var_dump($lastEmpty); // Output: null
?>7. CLI: php --ini=diff to Output Non-Default INI Directives
In CLI environments, PHP 8.5 introduces a new option for the php command: --ini=diff. This option outputs a list of INI directives that differ from their default values.
Explanation: This feature is particularly useful when you want to compare the current PHP configuration with the default settings. It simplifies debugging and managing configurations across different environments.
Example:
php --ini=diffRunning the above command will output a list of configuration directives that differ from their default values.
Deprecations in PHP 8.5
Along with new features, each major PHP version also deprecates older features or functions that are no longer recommended. PHP 8.5 continues this trend by removing certain deprecated features.
- Deprecation of MHASH_ Constants*: In PHP 8.5, the
MHASH_*constants, previously part of the deprecatedmhashextension, are officially removed.
Conclusion
PHP 8.5 promises to bring valuable improvements and new features, from small utilities to profound changes in core and extensions. With new functions like curl_multi_get_handles(), get_exception_handler(), array_first(), and stack trace support for fatal errors, PHP 8.5 will help developers write more efficient code, debug more easily, and build more powerful, stable PHP applications. Get ready to explore and leverage the benefits that PHP 8.5 will offer when it’s officially released in November 2025!







