Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up

What does the readonly property modifier introduced in PHP 8.1 do?

  1. A Prevents the property being written after initialisation
  2. B Makes the property private
  3. C Prevents the class being extended
  4. D Caches the property value
Answer

Prevents the property being written after initialisation

readonly combined with promoted constructor properties makes immutable value objects straightforward, which was awkward before.

All Php MCQs

Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up as