Mengintip Beberapa Fitur Baru di PHP

If you’ve ever studied backend classes in Dicoding, then you should be familiar with JavaScript. Apart from JavaScript, one of the programming languages that is widely used to build web backends is PHP. First created by Rasmus Lerdorf in 1994 with the extension Personal Home Page. It was only then, around 1997, that the PHP acronym changed to PHP: Hypertext Preprocessor as we know it today. It’s interesting, because the name PHP turns out to be a recursive abbreviation.

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


Board Members Email List

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.

Leave a comment

Your email address will not be published. Required fields are marked *