Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

What's new in PHP 8.5

What's new in PHP 8.5

Avatar for Christian Leo-Pernold

Christian Leo-Pernold

December 01, 2025
Tweet

More Decks by Christian Leo-Pernold

Other Decks in Technology

Transcript

  1. About me · ! Christian Leo-Pernold · "#$%&'()⛰+,- · .

    @[email protected] · / @mazedlx.bsky.social · ⭐ github.com/mazedlx · 1 mazedlx.net · 2 instagram.com/mazedlx · 3 linkedin.com/in/mazedlx 2/51
  2. Version History and EOL1,2 5.6 2018-12-31 (2.527 days ago) 7.0

    2019-01-19 (2.508 days ago) 7.1 2019-12-31 (2.162 days ago) 7.2 2020-11-30 (1.827 days ago) 7.3 2021-12-06 (1.456 days ago) 7.4 2022-11-28 (1.099 days ago) 8.0 2023-11-26 (736 days ago) 8.1 2025-12-31 (in 30 days from now) 8.2 2026-12-31 (in 395 days from now) 8.3 2027-12-31 (in 760 days from now) 8.4 2028-12-31 (in 1.126 days from now) 1,2 https://www.php.net/supported-versions.php and https://www.php.net/eol.php 3/51
  3. URLs5 were originally defined by Tim Berners-Lee [...], but [...]

    other specifications have also emerged, out of which RFC 3986 and WHATWG URL are the most notable ones. The former one updates the original RFC 1738 and defines URIs6, while the latter one specifies how browsers should treat URLs.7 — From the RFC 7 https://wiki.php.net/rfc/url_parsing_api 6 Uniform Resource Identifier, e.g. <www.php.net> 5 Uniform Resource Locator, e.g. https://www.php.net 7/51
  4. Use WHATWG for URLs to be rendered in a browser,

    for everything else use RFC 3986 — Volker 'edorian' Dusch (PHP 8.5 release manager) 9/51
  5. $url = new Uri\WhatWg\Url("HTTPS://bob:p%61ss@exämple.com:443" . "/foo?bar=baz#qua"); $url->getScheme(); // https $url->getUsername();

    // bob $url->getPassword(); // p%61ss $url->getAsciiHost(); // xn--exmple-cua.com $url->getUnicodeHost(); // exämple.com $url->getPort(); // 443 $url->getPath(); // foo $url->getQuery(); // bar=baz $url->getFragment(); // qua 10/51
  6. $greeting = 'hello-world!'; $greeting = implode( ' ', array_map( 'ucfirst',

    explode( '-', $greeting ) ) ); var_dump($greeting); // Hello World! 12/51
  7. $greeting = 'hello-world!'; $greeting = explode('-', $greeting); $greeting = array_map(ucfirst(...),

    $greeting); $greeting = implode(' ', $greeting); var_dump($greeting); // Hello World! 13/51
  8. $greeting = 'hello-world!' |> (fn (string $greeting) => explode('-', $greeting))

    |> (fn (array $parts) => array_map(ucfirst(...), $parts)) |> (fn (array $parts) => implode(' ', $parts)); var_dump($greeting); // Hello World! 14/51
  9. $ php --ini=diff Non-default INI settings: error_reporting: (none) -> "30719"

    html_errors: "1" -> "0" implicit_flush: "0" -> "1" max_execution_time "30" -> "0" mysqli.default_host: (none) -> "" 17/51
  10. PHP errors do not provide backtraces, which can make it

    difficult to ascertain their underlying cause. Enabling backtraces for fatal errors will provide vital information to developers debugging production applications. — Eric Norris (from the RFC) 21/51
  11. Fatal error: Maximum execution time of 1 second exceeded in

    example.php on line 6 Stack trace: #0 example.php(6): usleep(100000) #1 example.php(7): recurse() #2 example.php(7): recurse() #3 example.php(7): recurse() #4 example.php(7): recurse() #5 example.php(7): recurse() #6 example.php(7): recurse() #7 example.php(7): recurse() #8 example.php(7): recurse() #9 example.php(7): recurse() #10 example.php(10): recurse() #11 {main} 24/51
  12. Stack traces are now available when dealing with · timeouts

    · out of memory errors · class redefinitions 25/51
  13. #[\NoDiscard("Must check status code")] function createTransaction(): TransactionResult { // ...

    } createTransaction(); // Warning: return value should not be ignored. 27/51
  14. $array = [ 'Alice', 'Bob', 'Charles', 'Debbie', 'Emily', ]; foreach

    ($array as $first) { break; } $first = reset($array); $first = array_values($array)[0]; 33/51
  15. array_first($array); // 'Alice' array_last($array); // 'Emily', array_first([1 => 'a', 0

    => 'b', 3 => 'c', 2 => 'd']); // 'a' array_last([1 => 'a', 0 => 'b', 3 => 'c', 2 => 'd']); // 'd' 34/51
  16. Since OPcache’s integration into the Open Source PHP project with

    PHP 5.5, OPcache has become an essential part of PHP, running PHP in production without OPcache is generally considered a mistake and any new features are expected to be compatible with OPcache. — From the RFC 37/51
  17. max_memory_limit=256M memory_limit=128M ini_get('max_memory_limit'); // "256M"; ini_get('memory_limit'); // "128M"; ini_set('memory_limit', '300M');

    // Warning: Failed to set memory_limit to 314572800 bytes. // Setting to max_memory_limit instead (currently: 268435456 bytes) in ... 41/51
  18. locale_is_right_to_left('en'); // false locale_is_right_to_left(''); // false locale_is_right_to_left('ar'); // true locale_is_right_to_left('ar-US');

    // true locale_is_right_to_left('he_IL'); // true locale_is_right_to_left('ar-XY'); // true 43/51
  19. · All MHASH_* constants deprecated · Non-canonical scalar type casts

    (boolean| double|integer|binary) deprecated · Returning non-string values from a user output handler is deprecated · Emitting output from custom output buffer handlers is deprecated 48/51
  20. Where to go from here? · Read the RFCs https://wiki.php.net/rfc

    · Read the blog by Brendt https://stitcher.io/ · Also https://php.watch/versions/8.5 · Follow @brendtgd on X <https://x.com/brendtgd> (or don't if you don't like Elon) · Download PHP 8.5 now! 49/51