What's New in PHP 8.5: A Comprehensive Overview

· Oskar Stark · 2 minutes to read
PHP 8.5

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.

Ready to upgrade to PHP 8.5?

Our team specializes in Symfony and PHP development, helping businesses migrate smoothly and leverage the latest features. Contact us to discuss your PHP 8.5 migration strategy.

This might also interest you

PHP 8.5 URI extension
Oskar Stark

PHP 8.5's New URI Extension: A Game-Changer for URL Parsing

PHP 8.5 introduces a powerful new URI extension that modernizes URL handling. With support for both RFC 3986 and WHATWG standards, the new Uri class provides immutable objects, fluent interfaces, and proper validation - addressing all the limitations of the legacy parse_url() function. This guide shows practical before/after examples and explains when to use each standard.

Read more
3 dog heads
Mathieu Santostefano

Bring Your Own HTTP client

Break free from rigid dependencies in your PHP SDKs. Learn how to use PSR-7, PSR-17, and PSR-18 standards along with php-http/discovery to allow users to bring their favorite HTTP client, whether it's Guzzle, Symfony HttpClient, or another. A must-read for PHP and Symfony developers.

Read more
the surface of the earth seen from the space with city lights forming networks
Imen Ezzine

HTTP Verbs: Your Ultimate Guide

HTTP Verbs Explained: Learn the basics of GET, POST, PUT, DELETE, and more. This article explains how they work, their applications, and their security implications.

Read more
2025 a year of celebrations for PHP with windows about API Platform, PHP, AFUP and Symfony
Jules Daunay

2025: a year of anniversaries for PHP, AFUP, Symfony and API Platform

2025 is going to be a big year for anniversaries. We will be celebrating the 20th anniversary of Symfony, the 30th anniversary of PHP, the 25th anniversary of AFUP and the 10th anniversary of API Platform. For SensioLabs, this is a major milestone that proves the longevity of the technologies in our ecosystem. We are proud to celebrate these anniversaries with the community all year long.

Read more
Blue ElePHPant on a computer
Imen Ezzine

Optimize Your PHP Code: 8 Functions You Need for Efficient Table Handling

If you want to become a good PHP developer, you must learn to work with arrays. Arrays are used a lot in PHP: temporarily store, organize, and process data before it's saved in a database. Knowing how to work with them efficiently will help you manage and process data more effectively.

Read more
Image of a desk with a laptop and monitor
Oskar Stark

Introducing PIE: The Modern PHP Extension Installer

Discover PIE, the new PHP Installer for Extensions, a modern tool that simplifies managing PHP extensions with a Composer-like workflow. Say goodbye to PECL complexities and streamline your development process with PIE.

Read more
SymfonyLive 2024
Jules Daunay

SymfonyLive Paris 2024: Two Days of Conference and Fun.

On March 28th and 29th, the SensioLabs team and the French-speaking Symfony community gathered at the Cité Internationale Universitaire in Paris for SymfonyLive Paris 2024. Were you not at this must-attend event? We’ll summarize it for you, but only because it’s you!

Read more
Some speaker
Jules Daunay

Discover our Symfony events in February 2024

February was a busy month for SensioLabs regarding events related to Symfony. We attended Symfony meetups and conferences in France, Switzerland, England and finally Canada. We invite you to join us in this article for our review of February. Enjoy reading!

Read more
Image