New Release Available

8.5

The future of PHP starts now. Faster. Cleaner. Powerful.

Scroll
Nov 2025
Release Date
24 Months
Active Support
36 Months
Security Fixes
Innovations

What's New

PHP 8.5 introduces game-changing features that revolutionize how you write modern PHP applications.

🌐

RFC 3986 and WHATWG URL compliant API

New URI extension for modern URL parsing

PHP < 8.5

$components = parse_url("https://php.net/releases/8.5/en.php");

var_dump($components['host']);
// string(7) "php.net"
                    
PHP 8.5

use Uri\Rfc3986\Uri;

$uri = new Uri("https://php.net/releases/8.5/en.php");

var_dump($uri->getHost());
// string(7) "php.net"
                    
📋

Clone with v2

Modify properties while cloning readonly objects

PHP < 8.5

final readonly class PhpVersion {
    public function __construct(
        public string $version = 'PHP 8.4',
    ) {}

    public function withVersion(string $version) {
        $newObject = clone $this;
        $newObject->version = $version;

        return $newObject;
    }
}

var_dump(new PhpVersion()->withVersion('PHP 8.5'));
// Fatal error: Uncaught Error:
// Cannot modify readonly property PhpVersion::$version
                    
PHP 8.5

final readonly class PhpVersion {
    public function __construct(
        public string $version = 'PHP 8.4',
    ) {}

    public function withVersion(string $version) {
        return clone($this, ['version' => $version]);
    }
}

$version = new PhpVersion();

var_dump(
    $version->withVersion('PHP 8.5'),
    $version->version,
);
                    
|>

Pipe Operator

Transform nested function calls into readable pipelines

PHP < 8.5

$input = ' Some kind of string. ';

$output = strtolower(
    str_replace(['.', '/', '…'], '',
        str_replace(' ', '-',
            trim($input)
        )
    )
);
                    
PHP 8.5

$input = ' Some kind of string. ';

$output = $input
    |> trim(...)
    |> (fn (string $string) => str_replace(' ', '-', $string))
    |> (fn (string $string) => str_replace(['.', '/', '…'], '', $string))
    |> strtolower(...);
                    
[]

array_first() and array_last()

Convenient array boundary access functions

PHP < 8.5

$php = [
    'php-82' => ['state' => 'security', 'branch' => 'PHP-8.2'],
    'php-83' => ['state' => 'active', 'branch' => 'PHP-8.3'],
    'php-84' => ['state' => 'active', 'branch' => 'PHP-8.4'],
    'php-85' => ['state' => 'upcoming', 'branch' => 'PHP-8.5'],
];

$upcomingRelease = null;
foreach ($php as $key => $version) {
    if ($version['state'] === 'upcoming') {
        $upcomingRelease = $version;
        break;
    }
}

var_dump($upcomingRelease);
                    
PHP 8.5

$php = [
    'php-82' => ['state' => 'security', 'branch' => 'PHP-8.2'],
    'php-83' => ['state' => 'active', 'branch' => 'PHP-8.3'],
    'php-84' => ['state' => 'active', 'branch' => 'PHP-8.4'],
    'php-85' => ['state' => 'upcoming', 'branch' => 'PHP-8.5'],
];

$upcomingRelease = array_first(
    array_filter(
        $php,
        static fn($version) => $version['state'] === 'upcoming'
    )
);

var_dump($upcomingRelease);
                    
⚠️

#[\NoDiscard] Attribute

Warn when function return values are ignored

PHP < 8.5

function getPhpVersion(): string {
    return 'PHP 8.4';
}

getPhpVersion(); // No Errors
                    
PHP 8.5

#[\NoDiscard]
function getPhpVersion(): string {
    return 'PHP 8.4';
}

getPhpVersion();
// Warning: The return value of function
// getPhpVersion() should either be used or
// intentionally ignored by casting it as (void)
                    
🎯

First Class Callables in Constant Expressions

Use closures and callables in attributes

PHP < 8.5

final class CalculatorTest extends \PHPUnit\Framework\TestCase
{
    #[DataProvider('subtractionProvider')]
    public function testSubtraction(
        int $minuend,
        int $subtrahend,
        int $result
    ): void
    {
        $this->assertSame(
            $result,
            Calculator::subtract($minuend, $subtrahend)
        );
    }

    public static function subtractionProvider(): iterable
    {
        for ($i = -10; $i <= 10; $i++) {
            yield [$i, $i, 0];
            yield [$i, 0, $i];
            yield [0, $i, -$i];
        }
    }
}
                    
PHP 8.5

final class CalculatorTest
{
    #[Test\CaseGenerator(static function (): iterable {
        for ($i = -10; $i <= 10; $i++) {
            yield [$i, $i, 0];
            yield [$i, 0, $i];
            yield [0, $i, ($i * -1)];
        }
    })]
    public function testSubtraction(
        int $minuend,
        int $subtrahend,
        int $result
    )
    {
        \assert(
            Calculator::subtract($minuend, $subtrahend) === $result
        );
    }
}
                    
🔗

Persistent cURL Share Handles

Simplified and improved cURL connection pooling

PHP < 8.5

$sh = curl_share_init();
curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT);

$ch1 = curl_init('https://php.net/');
curl_setopt($ch1, CURLOPT_SHARE, $sh);
curl_exec($ch1);

$ch2 = curl_init('https://thephp.foundation/');
curl_setopt($ch2, CURLOPT_SHARE, $sh);
curl_exec($ch2);

curl_share_close($sh);

curl_close($ch1);
curl_close($ch2);
                    
PHP 8.5

$sh = curl_share_init_persistent([
    CURL_LOCK_DATA_DNS,
    CURL_LOCK_DATA_CONNECT
]);

$ch1 = curl_init('https://php.net/');
curl_setopt($ch1, CURLOPT_SHARE, $sh);
curl_exec($ch1);

$ch2 = curl_init('https://thephp.foundation/');
curl_setopt($ch2, CURLOPT_SHARE, $sh);
curl_exec($ch2);

curl_close($ch1);
curl_close($ch2);
                    
More Improvements

Additional Features

🏷️

Property Promotion for Final

Constructor property promotion now available for final properties, reducing boilerplate code.

🔖

Attributes for Constants

Apply attributes to class constants for better metadata support and documentation.

#[\Override] for Properties

The Override attribute now works on properties, catching inheritance errors at compile time.

⚠️

#[\Deprecated] for Traits

Mark traits as deprecated to guide developers away from legacy code patterns.

🔒

Asymmetric Visibility for Static Properties

Define different read/write visibility levels for static properties.

⏱️

#[\DelayedTargetValidation]

New attribute for deferring target validation in attribute processing.

🔍

Handler Introspection

Access error and exception handlers with get_error_handler() and get_exception_handler().

🌳

Enhanced DOM Methods

New getElementsByClassName() and insertAdjacentHTML() methods for DOM manipulation.

📝

Enchant Dictionary Functions

New enchant_dict_remove_from_session() and enchant_dict_remove() for spell checking.

📏

grapheme_levenshtein()

Calculate Levenshtein distance for Unicode grapheme clusters.

OPcache File Cache Check

New opcache_is_script_cached_in_file_cache() function for cache validation.

🪞

Enhanced Reflection

New ReflectionConstant and ReflectionProperty methods for deeper code introspection.

Breaking Changes

Deprecations

PHP 8.5 maintains strong backward compatibility with minimal breaking changes.

Clean Upgrade Path

PHP 8.5 focuses on adding new features while maintaining compatibility. No major deprecations in this release. Check the migration guide for detailed information.

Roadmap

Support Timeline

Long-term support commitment for enterprise-grade stability and security.

01
November 20, 2025

General Availability

PHP 8.5.0 released to production with full feature set, comprehensive documentation, and migration guides.

02
November 2027

Active Support Ends

Transition to security-only updates. Bug fixes and general maintenance conclude after two years.

03
November 2028

End of Life

Security support concludes. Migration to PHP 8.6+ strongly recommended for continued protection.

Ready to Evolve?

Download PHP 8.5 and experience the next generation of web development.