Programming Languages PHP Objective
Sep 23, 2025

Which PHP 8.2 feature allows you to mark class properties as readonly in the constructor?

Choose the correct answer:
A) readonly keyword
B) const keyword
C) final keyword
D) immutable keyword
Detailed Explanation

Explanation: PHP 8.1 introduced readonly properties and PHP 8.2 extended this with readonly classes. The readonly keyword ensures properties can only be initialized once and cannot be modified afterward, providing immutability.

Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback