---
title: "PHP 8.5 now officially released"
canonical_url: "https://www.zone.eu/blog/php-8-5-now-officially-released/"
post_type: "post"
published: "2025-12-08T11:08:18+00:00"
modified: "2026-04-21T12:36:29+00:00"
author: "Ingmar Aasoja"
featured_image: "https://www.zone.eu/static/sites/2/2025/12/PHP-8.5-now-officially-released.webp"
taxonomies:
  category:
    - name: "Updates"
      url: "https://www.zone.eu/blog/category/updates/"
  post_tag:
    - name: "PHP 8.5"
      url: "https://www.zone.eu/blog/tag/php-8-5/"
---

# PHP 8.5 now officially released

**At the end of November, PHP version 8.5 was officially released. [Zone servers](https://www.zone.eu/web-hosting/) have offered early access for several months already, starting from the beta phase. Each new version deprecates outdated features and introduces fresh improvements. In this article, we focus on the most notable new capabilities.**

![PHP 8.5 now officially released](https://www.zone.eu/static/sites/2/2025/12/PHP-8.5-now-officially-released-1024x577.webp)## The Pipe Operator (|&gt;)

This is arguably one of the coolest syntax updates in years – something PHP developers could hardly have imagined not too long ago. It significantly improves code readability and makes everyday development more fluent.

The pipe operator is especially useful when working with arrays and strings. If achieving the final result requires passing a variable through several functions, you can now chain them together more elegantly.

Example of removing odd numbers from a sequence:

#### PHP 8.4

```php
$numbers = implode(',',
    array_filter(
        explode(',', '1,2,3,4,5,,6'),
            function ($var) {
                  return $var && !($var & 1);
            }
      )
);

echo $numbers; // 2,4,6
Code language: PHP (php)
```

#### PHP 8.5

```php
$numbers = '1,2,3,4,5,,6'
    |> (fn($s) => explode(',', $s))
    |> (fn($xs) => array_filter($xs, fn($var) => $var && !($var & 1)))
    |> (fn($xs) => implode(',', $xs));

echo $numbers; // 2,4,6
Code language: PHP (php)
```

## `array_first` and `array_last` Functions

As the names suggest, these new functions return the first and last values of an array. Earlier, `array_key_first` and `array_key_last` helped somewhat, but developers still needed to manually check whether the elements existed at all.

#### PHP 8.4

```php
$names = ['john', 'smith'];
$lastName = $names === [] ? null : $names[array_key_last($names)];

echo $lastName; // smithCode language: PHP (php)
```

#### PHP 8.5

```php
$names = ['john', 'smith'];
$lastName = array_last($names);

echo $lastName; // smithCode language: PHP (php)
```

## Stack Trace in Fatal Error Messages

When a program crashed due to a fatal error, it was often difficult to pinpoint where the underlying issue actually occurred. PHP 8.5 now provides a more informative stack trace in fatal error messages. Note: this requires enabling `fatal_error_backtraces = On` in your `php.ini` configuration.

```php
ini_set('memory_limit', '2M');

$dates = [];

function collectDates($dates) {
    while (true) {
        $dates[] = time();
    }
}

collectDates($dates);Code language: PHP (php)
```

#### PHP 8.4 output:

```
Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 2097160 bytes) in /test.php on line 9
```

#### PHP 8.5 output:

```php
Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 2097160 bytes) in /test.php on line 9
Stack trace:
#0 /test.php(13): collectDates(Array)
#1 {main}Code language: PHP (php)
```

## URI Extension

Previously, extracting information from a URL required parsing it manually and checking whether the needed part was present. PHP 8.5 introduces a dedicated extension that simplifies this process:

#### PHP 8.4

```php
$parsed = parse_url('https://example.com:80');

echo $parsed['port'] // 80
echo $parsed['path'] // Warning: Undefined array key "path" ...Code language: PHP (php)
```

#### PHP 8.5

```php
use Uri\Rfc3986\Uri;

$uri = new Uri('https://example.com:80');

echo $uri->getPort(); // 80
echo $uri->getpath(); // ""
echo $uri->withPort(null)->toString(); // https://example.comCode language: PHP (php)
```

## \#\[\\NoDiscard\] Attribute

When a function’s return value matters, developers can now enforce its usage by adding the `#[\NoDiscard]` attribute. This helps catch situations where an important return value might otherwise be ignored.

#### PHP 8.4

```php
function getName() {
    return 'Sohn Smith';
}

getName();Code language: PHP (php)
```

#### PHP 8.5

```php
#[\NoDiscard]
function getName() {
    return 'Sohn Smith';
}

getName();

// Warning: The return value of function getName() should either be used or intentionally ignored by casting...Code language: PHP (php)
```

## Kokkuvõtteks

Summary

More detailed information about this release is available on the official PHP website, which now includes [a dedicated page](https://www.php.net/releases/8.5/en.php) for PHP 8.5. It’s also worth noting that security updates for PHP 8.1 will end in late 2025, and PHP 8.3 is transitioning from active support to security-only updates. We strongly recommend updating existing applications to the newest version as soon as possible. [Laravel 12](https://github.com/laravel/framework/releases/tag/v12.40.0) and the newly released [Symfony 8.0](https://symfony.com/releases/8.0) already offer full support for PHP 8.5.
