PHP, one of the most popular programming languages for web development, has been continuously evolving to meet the growing demands of developers and businesses alike. With the upcoming release of PHP 8.4 on november 21st, the language is set to introduce a series of exciting features and improvements that promise to make coding more efficient, secure, and readable. Let’s check it out!
Multi-byte String Handling
Historically, PHP has lacked built-in functions for handling multi-byte strings with the same ease as single-byte strings. Functions like ucfirst and lcfirst, which capitalize or lowercase the first character of a string, did not work with multi-byte characters, leading to complex and error-prone custom implementations. PHP 8.4 addresses this gap by introducing five new functions:
- mb_ucfirst
- mb_lcfirst
- mb_trim
- mb_ltrim
- mb_rtrim
These functions simplify the handling of Unicode characters, enhancing the readability and standardization of PHP code. While they don’t cover the entire breadth of Unicode, which includes complex issues like character mapping across different encoding standards, they represent a significant step forward.
Security Enhancements
Security has always been a paramount concern in web development, and PHP 8.4 is taking steps to fortify its defenses. Since the introduction of the password hashing API in PHP 5.5, the bcrypt algorithm has been the standard for securing user passwords. However, over time, computing power has increased, making older hashing methods less secure. PHP 8.4 increases the default cost of bcrypt from 10 to 12, making the hashing process more computationally intensive. This change is expected to deter attackers from attempting to crack passwords, as the process will require significantly more time and resources.
JIT and Performance Tweaks
Just-In-Time (JIT) compilation was a groundbreaking feature introduced in PHP 8.0, but it came with a steep learning curve due to its complex configuration. PHP 8.4 aims to simplify JIT setup and improve its performance. The new JIT compiler generates an Intermediate Representation (IR) which is optimized and translated into native code, resulting in faster execution and smaller code size. This change not only improves performance but also makes it easier for developers to harness the power of JIT compilation.
New HTML5 Support
Modern web development requires robust handling of HTML5 content, and PHP 8.4 delivers with the introduction of the \Dom\HTMLDocumentand DOM\XMLDocument classes. These new classes replace the outdated \DOMDocument and provides full support for HTML5 parsing, ensuring compatibility with the latest web standards.
Example:
$html = file_get_contents('https://dias.dev');
$dom = DOM\HTMLDocument::createFromString($html);
echo $dom->title;New Array Functions
Arrays are a fundamental data structure in PHP, and PHP 8.4 enriches the language with several new array functions: array_find(), array_find_key(), array_any(), and array_all(). These functions simplify common array operations, reducing the need for third-party libraries and making array manipulation more intuitive and efficient.
Simplified New Syntax
Finally, PHP 8.4 introduces a more streamlined syntax for chaining methods, properties, and constants directly after class instantiation. This change eliminates the need for parentheses, making the code cleaner and more readable. For instance, $name = new MyClass()->execute(); replaces the previous $name = (new MyClass())->execute();.
PHP 8.4 heralds a wave of enhancements. These updates, alongside other improvements, position PHP 8.4 as a very exciting release, that will bring many quality of life and performance improvements.




