ReadOnly properties with PHP 8.1 🐘

ReadOnly properties with PHP 8.1 🐘

Let's learn how you can efficiently use the new keyword readonly introduced by PHP 8.1 🐘

By declaring class properties β€œreadonly”, the properties will only be allowed to be initialized once. Any further attempts to give another value will throw an error as it won’t be allowed.

🏁 My Udemy course on how to build a real-world PHP 8 application from scratch has just been released: udemy.com/course/create-real-world-php-weba..

Β