JUST RELEASED

PHP 8.5

Modern. Powerful. Refined.

Upgrade to PHP 8.5 →

A Major Step Forward

PHP 8.5 brings powerful new features including a standards-compliant URI extension, enhanced object cloning, the pipe operator for cleaner code, and significant performance improvements.

What's New

Explore the headline features that make PHP 8.5 exceptional

🌐

RFC 3986 & WHATWG URL API

Native, standards-compliant URI parsing with the new Uri extension. Clean, object-oriented API for working with URLs.

New Extension View example →
📋

Clone with Properties

Modify properties while cloning objects, including readonly properties. Perfect for immutable value objects.

Language Feature View example →

Pipe Operator

Write cleaner, more readable code by chaining function calls with the new pipe operator syntax.

Syntax View example →
⚠️

#[\NoDiscard] Attribute

Mark return values as important. Get warnings when critical function results are ignored.

Attribute View example →
🔧

First-Class Callables

Use closures and first-class callables in constant expressions and attributes for more powerful metaprogramming.

Enhancement View example →
🔗

Persistent cURL Handles

Improved performance with persistent cURL share handles. Better connection reuse across requests.

Performance View example →

See the Difference

RFC 3986 Compliant URI API

View RFC →
PHP < 8.5
$components = parse_url("https://php.net/releases/8.5"); var_dump($components['host']); // string(7) "php.net"
PHP 8.5
use Uri\Rfc3986\Uri; $uri = new Uri("https://php.net/releases/8.5"); var_dump($uri->getHost()); // string(7) "php.net"

Clone with Property Modification

View RFC →
PHP < 8.5
final readonly class PhpVersion { public function __construct( public string $version = 'PHP 8.4', ) {} public function withVersion(string $version) { $new = clone $this; $new->version = $version; return $new; } } // Fatal error: Cannot modify readonly property
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 ]); } } // Works perfectly! ✓

Pipe Operator for Readable Code

View RFC →
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 $s) => str_replace(' ', '-', $s)) |> (fn(string $s) => str_replace(['.', '/', '…'], '', $s)) |> strtolower(...);

New #[\NoDiscard] Attribute

View RFC →
PHP < 8.5
function getPhpVersion(): string { return 'PHP 8.4'; } getPhpVersion(); // No warnings
PHP 8.5
#[\NoDiscard] function getPhpVersion(): string { return 'PHP 8.5'; } getPhpVersion(); // Warning: Return value should be used

First-Class Callables in Constant Expressions

View RFC →
PHP < 8.5
final class CalculatorTest { #[DataProvider('subtractionProvider')] public function testSubtraction( int $minuend, int $subtrahend, int $result ): void { // Test implementation } public static function subtractionProvider(): iterable { for ($i = -10; $i <= 10; $i++) { yield [$i, $i, 0]; } } }
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 Handle

View RFC →
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); // No need to close - persistent handle! curl_close($ch1); curl_close($ch2);

Even More Improvements

Language Enhancements

  • Property promotion for final classes
  • Attributes for constants
  • #[\Override] for properties
  • #[\Deprecated] for traits
  • Asymmetric visibility for static properties

New Functions

  • array_first() and array_last()
  • get_error_handler()
  • get_exception_handler()
  • grapheme_levenshtein()
  • curl_multi_get_handles()

Extended Functionality

  • DOM API improvements
  • Reflection enhancements
  • Enchant dictionary functions
  • OPcache file cache checking
  • Performance optimizations

Ready to Upgrade?

Better performance. Better syntax. Improved type safety.

Download PHP 8.5 Now →