What’s New in PHP 8.4? Release Date, HTML5 DOM, Bcrypt Cost, XML Parsing, and mbstring Trims

PHP 8.4, scheduled for release on 2024‑11‑21, introduces HTML5‑aware DOM parsing, raises the default bcrypt cost to 12, adds a reliable large‑XML parsing option, and provides new multibyte trim functions, offering developers enhanced security and easier string handling.

Open Source Tech Hub
Open Source Tech Hub
Open Source Tech Hub
What’s New in PHP 8.4? Release Date, HTML5 DOM, Bcrypt Cost, XML Parsing, and mbstring Trims

When is the release?

According to the preparation schedule, PHP 8.4 will be released on 2024‑11‑21, after three alpha versions, three beta versions, and six release‑candidate versions.

PHP 8.4 New Features

DOM extension now supports HTML5

The DOM extension in PHP 8.4 has been upgraded to support HTML5 parsing and serialization, eliminating headaches when handling HTML5‑specific tags or embedding HTML in JavaScript.

Use the new DOM\HTMLDocument class to process HTML5 content in a standards‑compliant way.

Example: creating an HTML document from a string:

use DOM\HTMLDocument;

$htmlDocument = HTMLDocument::createFromString('<!DOCTYPE html><html><body>Hello, HTML5!</body></html>');

Or creating from a file:

use DOM\HTMLDocument;

$htmlDocument = HTMLDocument::createFromFile('path/to/your/file.html');
Learn more: https://wiki.php.net/rfc/domdocument_html5_parser

Default bcrypt cost increased

In PHP 8.4 the default bcrypt cost is raised to 12. Bcrypt is the password‑hashing function used by PHP; a higher cost makes brute‑force attacks slower.

The cost (or "work factor") can be adjusted—higher values increase protection because bcrypt is an adaptive function that can be made slower over time.

The practical impact is only a few milliseconds slower hashing.

PHP RFC: https://wiki.php.net/rfc/bcrypt_cost_2023

More reliable parsing of large XML documents

This change fixes potential issues in the ext/xml extension when handling large XML files.

Modifications in libxml2 version 2.7.0 unintentionally broke large‑document parsing when using xml_parse() or xml_parse_into_struct().

PHP 8.4 introduces a new parser option that correctly processes huge XML documents, preventing parsing errors without requiring complex work‑arounds.

PHP RFC: https://wiki.php.net/rfc/xml_option_parse_huge

New multibyte trim functions

The mbstring extension now includes three new functions: mb_trim(), mb_ltrim(), and mb_rtrim(), making it easier to trim multibyte strings compared with previous regex‑based solutions.

These functions handle whitespace and other characters in a multibyte‑safe manner. By default they trim a predefined set of characters, including many Unicode spaces not covered by \s.

Function signatures: mb_trim($string, $characters): trims characters from both ends of the string. mb_ltrim($string, $characters): trims characters from the start (left) of the string. mb_rtrim($string, $characters): trims characters from the end (right) of the string.

By default, $characters includes various whitespace characters, though not every possible Unicode character due to storage and compatibility constraints.

PHP RFC: https://wiki.php.net/rfc/mb_trim
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Backend DevelopmentPHPXMLDOMPHP 8.4mbstring
Open Source Tech Hub
Written by

Open Source Tech Hub

Sharing cutting-edge internet technologies and practical AI resources.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.