Since many years ago
Not a few developers have thought that PHP is an old school language, has many weaknesses, and will die soon. However, the fact is that there Board Members Email List are still many websites out there that are built with PHP. Based on data from W3Techs, PHP is still used on more than 74% of websites in the world. In addition, JetBrains’ The State of Developer Ecosystem 2022 survey shows PHP is ranked as the 7th most favorite programming language used by developers.
PHP has been improving since the major release of PHP 7.4. Many improvements and new features are presented to improve performance and developer experience. Even at the end of 2021, The PHP Foundation was formed to ensure the continued development of this language. Currently the latest stable release to work with is PHP 8.2. What are some interesting new features for us to implement? Here are some of them.
Constructor Property Promotion
In previous versions, to explicitly define a property of a class, we needed to write it at the top of the class. Then when we want to set its value when the CRYP Email List class is instantiated, we need to write quite a bit of code, depending on how many properties the class has. Examples like this.
Besides being long, the code above also repeats the same keywords a lot, such as name, birthday, and address. As of PHP 8, the above code can be summarized using the property promotion constructor. This feature allows us to write a class constructor as well as initialize and set property values with a much shorter syntax so that we can summarize the above code as follows.