What’s new in PHP 8.4

Released: November 21, 2024 • Active support: 2 years • Security support: +2 years • EOL: December 31, 2028

Key New Features

1) Property Hooks

Define get and/or set hooks directly on properties to reduce boilerplate and enable virtual properties.

// Example (illustrative)
class User {
    public string $name {
        get { return ucfirst($this->_name); }
        set { $this->_name = trim($value); }
    }
    private string $_name = '';
}

2) Asymmetric Visibility

Allow different visibility for reading vs. writing a property.

class Post {
    public private(set) string $slug;
    public function __construct(string $slug) {
        $this->slug = $slug; // write allowed here
    }
}

3) Chain new Without Parentheses

Parentheses are no longer required when chaining after new.

$request = new Request()->withMethod('GET')->withUri('/hello');

4) New Array Helpers

  • array_find() – first matching element
  • array_find_key() – key of first match
  • array_any() – any element matches
  • array_all() – all elements match
$n = array_find($numbers, fn($x) => $x % 2 === 0); // first even

5) HTML5 DOM

New DOM classes add proper HTML5 parsing and manipulation (beyond legacy HTML4 limitations).

6) Multibyte String Additions

  • mb_trim(), mb_ltrim(), mb_rtrim()
  • mb_ucfirst(), mb_lcfirst()

7) BCMath

bcdivmod() combines division and modulus for arbitrary-precision numbers.

8) Intl / Grapheme / cURL updates

  • grapheme_str_split()
  • Intl: intltz_get_iana_id(), IntlTimeZone::getCanonicalID()
  • cURL: HTTP/3-related constants and options; new timing info fields

9) Other Notables

  • phpinfo() shows integer size
  • New rounding behavior (invalid modes throw ValueError)
  • DateTime/Immutable: createFromTimestamp(), getMicrosecond(), setMicrosecond()
  • HTTP helpers: request_parse_body(), http_get_last_response_headers(), http_clear_last_response_headers()

Syntax & Functional Changes

  • exit and die are now functions (not language constructs)
  • Default bcrypt cost increased from 10 → 12
  • PHP_ZTS and PHP_DEBUG now booleans
  • Raised minimums: OpenSSL ≥ 1.1.1, libcurl ≥ 7.61.0
  • CURLOPT_DNS_USE_GLOBAL_CACHE ignored
  • mbstring Unicode Character Database updated

Deprecations

  • Implicitly nullable type declarations
  • E_STRICT constant
  • session_set_save_handler() with > 2 args
  • CSV functions without explicit $escape parameter
  • SUNFUNCS_RET_* constants
  • CURLOPT_BINARYTRANSFER
  • …and more as part of ongoing cleanup

Removals / Moved to PECL

  • Pspell
  • IMAP
  • OCI8, PDO-OCI

Release & Support

Release: November 21, 2024
Support policy: 2 years active (bugs & security) + 2 years security-only
End of life: December 31, 2028

Summary Table

CategoryHighlights
New CapabilitiesProperty hooks, asymmetric visibility, chainable new, array helpers, HTML5 DOM, new mb_*, BCMath, Intl/Grapheme/cURL updates
Syntax / Internalsexit/die become functions; bcrypt cost↑; rounding throws on invalid modes; updated libs & UCD
DeprecatedImplicit nullable types, E_STRICT, session_set_save_handler() (3+ args), CSV escape default, sunfuncs constants, etc.
RemovedPspell, IMAP, OCI8, PDO-OCI moved to PECL
ReleaseNov 21, 2024 • EOL Dec 31, 2028

Tip: Test on a staging environment and enable deprecation warnings to prep for 8.5.

Leave a Comment

Licensed under CC BY-NC 4.0

DevOps viewpoints are those of its owner. You may share and adapt this article for non-commercial purposes, provided proper attribution is given. Attribution should include:

Title: What’s new in PHP 8.4
Author: peter arthur martin
Original URL: https://www.woodcentral.com/-/peter/whats-new-in-php-8-4/
License: CC BY-NC 4.0

Site Index

👍 This page answered my questions

Your vote helps other woodworkers quickly find the answers and techniques that actually work in the shop.