PHP, the widely used programming language around the world, last November 23rd recently announced the release of PHP 8.3, the latest major annual update. This new version brings with it a series of new features and improvements, keeping PHP up to date with the current needs of web development.
A new version of PHP is released approximately every 12 months, with the latest release being 8.2 in December 2022. Each release has two years of active support and one year of security support, so 8.0 – released on November 26 2020 – will exit security support in a few days, although operating system vendors may have their own support policies that include PHP. It is common for versions of PHP that have been out of support for a long time to remain in use, and a report earlier this year stated that the majority of implementations are in this state.
Main new features of PHP 8.3
- Dynamic Access to Class Constants: A new syntax has been introduced that allows dynamic access to class constants, simplifying interaction with them.
- Improved Management of Dates and Times: More appropriate exceptions have been implemented for handling dates and times, making the processing of this information more intuitive and less error-prone.
- json_validate() function: This added feature allows validation of JSON strings, a crucial feature in the era of data interoperability.
- Attribute #[\Override]: Implemented to test for the existence of a method in a parent class or implemented interface, making it easier to handle inheritance and polymorphism.
- Updated Zip Extension: New methods for setting and getting archive flags have been added, improving manipulation of compressed files.
- Extended POSIX Support: The addition of features like posix_sysconf and posix_eaccess enriches PHP support for POSIX standards.
- New Options for PHP Sockets: Adding these options expands the network communication possibilities in PHP.
- Randomizer Class: Introducing new features for the Randomizer class, enhancing the generation of random numbers.
- Updated cURL support: Support for new cURL options and constants up to version 7.87, essential for HTTP requests.
- New DOM Methods: Adding methods for DOM nodes and elements facilitates manipulation of the Document Object Model.
- Rounding in number_format(): You can now round to negative digits, allowing greater flexibility in formatting numbers.
- Support for zend_call_stack_get on OpenBSD: Extends PHP compatibility with different operating systems.
- Linting of Multiple Files: The ability to lin multiple files at once with the php -l option.
- Negative Indexes in Arrays: This support offers new dynamics in array management.
- Anonymous Read Only Classes: Introduces greater security and encapsulation into your code.
- Typed Class Constants: You can now declare types for class, interface, trait, and enum constants.
- Closures from Magical Methods with Named Arguments: This feature makes closures more versatile and powerful.
- STREAM_NOTIFY_COMPLETED: A new notification for PHP streams, improving data stream management.
- Bug Fixes and Other Improvements: A series of bug fixes and various improvements that make PHP 8.3 a more stable and performant version.
Performance and Benchmarks PHP 8.3
From the research and benchmarks available, it can be seen that there are no significant differences in terms of performance between PHP 8.2 and PHP 8.4. This suggests that, as of version 8.1, PHP appears to have reached a plateau in terms of performance. This scenario implies that current performance could remain constant throughout Branch 8 and into the next few years, unless a radical revision of the language is undertaken. Such an overhaul could aim to overcome current limitations and push PHP's capabilities further, raising the performance bar.