Unveiling PHP 8.4 Release – The next big leap in web development!
PHP, the backbone of countless web applications, is set to release its latest version, PHP 8.4, on November 21, 2024. This release promises to bring a host of new features, improvements, and changes designed to make the language more powerful and user-friendly for developers.
Let’s dive into what’s new in PHP 8.4 and why it’s worth getting excited about.
Key features that are expected in new PHP 8.4!
Property hooks
One of the most anticipated features of PHP 8.4 is property hooks. This feature allows developers to define custom “get” and “set” behaviors of class properties. Inspired by languages like Kotlin and Swift, property hooks simplify the creation of accessors and mutators, reducing boilerplate code and making the codebase cleaner and more maintainable.
Enhanced array functions
PHP 8.4 introduces several new array functions such as ‘array_find’, ‘array_find_key’, ‘array_any’, and ‘array_all’. These functions make it easier to perform common operations on arrays, providing more expressive and concise ways to handle array data.
Improved DateTime handling
The DateTime class sees significant enhancements with new methods like ‘DateTime(Immutable) : :createFromTimestamp’. These methods offer finer control over date and time manipulation including microsecond precision and easier timestamp conversions.
Advanced string manipulation
String handling in PHP gets a boost with the addition of new functions such as ‘mb_ucfirst’ and ‘md_lcfirst’ for multibyte strings, and ‘mb_trim’,‘mb_ltrim’, and ‘md_rtrim’ for trimming operations. These additions enhance PHP’s ability to handle complex string manipulations more effectively.
Some functions in PHP 8.4 and their default behaviors:
‘mb_trim($string, $characters)’: it trims characters from both ends of a string.
‘mb_ltrim($string, $characters)’: it trims characters from the left side beginning of a string.
‘mb_rtrim($string, $characters)’: it trims characters from the end (right side) of a string.
$characters include several whitespace characters by default. However, not all Unicode characters are included due to storage and compatibility concerns.
HTTP and CURL enhancements
PHP 8.4 introduces new HTTP functions like ‘http_(get|clear)_last_response_headers’, which provide better control over HTTP response headers.
Additionally, ‘curl_version()’ now supports a feature list, giving developers more information about the capabilities of their Curl setup.
Large XML documents can be parsed reliably now
There is a potential issue in the ext/xml PHP extension about the handling of large XML document parsing. The risk of this issue has vanished by including this change in PHP 8.4.
Conflicting modifications in libxmk2 v 2.7.0 unintentionally disrupted large document parsing when using xml_parse() and xml_parse_into_struct() functions, resulting in a parsing error.
Nevertheless, PHP 8.4 introduced a new parser option to handle large XML documents and mitigate parsing errors. It will be a help for developers to parse large XML documents without having to perform complex workarounds.
Deprecations and removals from PHP 8.4
As part of its continuous improvement, PHP 8.4 deprecates certain features to streamline the language and encourage best practices:
Implicitly nullable parameters
These are deprecated to avoid ambiguity and promote explicit nullability in function parameters.
CURLOPT_BINARYTRANSFER option
The Curl option is deprecated, simplifying Curl usage.
Additionally, some extensions are moved from the PHP core to PECL, including the OCI8, PDO-OCI, and IMAP extensions, indicating a shift towards a more modular PHP core.
Syntax and Functionality changes
Open SSL: minimum required version increased to 1.1.
In PHP, Open SSL extension helps with encryption, key exchange, authentication, generic hashing functionality and password hashing to PHP. It uses the Open SSL library to provide its functionalities.
Thus, PHP 8.4 and later versions will use the OpenSSL extension 1.1.1 instead of 1.0.1.
Rounding mode improvements
The ‘round()’ function in PHP 8.4 throws ‘\ValueError’ exceptions for invalid rounding modes, ensuring stricter and more predictable behavior in numerical operations.
Password hashing: default Brypt cost changed from 10 to 12
In PHP 8.4, the cost parameter of the password_default/password_bcrypt algorithm has changed from 10 to 12 to make the passwords more challenging to calculate given the more capable hardware available compared to when the default value was decided.
The change is equivalent to:
password_hash('hunter2', PASSWORD_BCRYPT, ['cost' => 10]); password_hash('hunter2', PASSWORD_BCRYPT, ['cost' => 12]);
Wrapping up
PHP 8.4 brings a range of enhancements that improve the developer experience by introducing powerful new features, refining existing functionality, and ensuring a cleaner, more consistent language. Whether a seasoned developer or a novice, the updates in PHP 8.4 offer valuable tools to help everyone build robust and efficient web applications.
Note the release date, which is November 21, 2024, and get ready to explore the latest advancements in PHP. For detailed information and other new feature updates, visit PHP 8.4: What's New and Changed, Hire our PHP developers for delivering custom web solution whether it’s a simple web solution, complex enterprise level application, ecommerce solution, CMS site and more. As a leading PHP development company, we build robust and scalable PHP web application that streamline business process and add value to your business. Whether you require new PHP website, upgrade your current website to any latest version of PHP 8.x; or want to migrate your website to PHP 8; we provide one-stop-solution. Get in touch with us via email us at [email protected].
More interesting content for you
89