Intermediate PHP
Q57 / 100

What is a PHP readonly property (PHP 8.1)?

Correct! Well done.

Incorrect.

The correct answer is B) A property that can only be initialized once; subsequent writes throw an error

B

Correct Answer

A property that can only be initialized once; subsequent writes throw an error

Explanation

public readonly string $name allows setting $name once (usually in __construct). Any subsequent write throws Error.

Progress
57/100