Home >Backend Development >PHP Tutorial >The overlooked new php features
Most of the posts about php 8.4 are about property hooks, asymmetric property visibility, the new array functions and the new html features.
But there are a few more features that deserve attention.
Before php 8.4 the only way to document deprecated code was to add a @deprecatedcomment tag. Now this is an attribute with message and since properties.
A use case could be adding it to an older version of the api.
[#\Deprecated(message: 'Use route /v2/something', since: 'v2')]
Before php 8.4 the drivers were a subsclasses of the PDO class. This meant that the subclass could have extra methods or not. Now you need to call the driver class that fits your database.
The main benefit is that the database is not only known by looking at the connection string.
Most developers know lazy loading from ORM entities. But now php made it a language feature. If you don't have expensive classes on creation, you probably don't need this feature.
This will improve the code for packages that use a lazy strategy.
If you are working with multibyte strings mb_trim(), mb_ltrim(), mb_rtrim(), mb_ucfirst(), and mb_lcfirst() can be a welcome addition.
The above is the detailed content of The overlooked new php features. For more information, please follow other related articles on the PHP Chinese website!