Research & Documentation 05 Php8

Research & Documentation 05 Php8

5R - PHP8

The new #[Override] attribute

This new attribute is used to show the intentions of a programmer, so for example if a parent method changes its method name, PHP will be able to detect that the child does not override anything and will throw an error.

json_validate()

In the past version, the only way you could validate whether a string was valid in JSON, was to decode it and detect for any errors thrown. The new json_validate() benefits if you only need to know whether the input is valid, since it uses less memory than to decode the string.

Magic method closures and named arguments

This works when you have a class that supports magic methods, which are special methods that override PHP default's action when certain ones are performed by on object. In the latest version allows you to create closures from methods, and then pass named arguments to those closures, which was not possible before.

Summary

Overall, their are multiple new features in the latest version of PHP 8.3. All useful features that allow the developer to create what they need and make the workflow more efficient. It truly is interesting how they design these new features by analyzing ways to help the developers who may need these certain tools.