Initialize Readonly On Child

../_images/initialize_readonly_on_child.png

Readonly properties could only be initialized in the same class as their definition. That holds true, whatever the visibility of the property: private, protected, private.

In PHP 8.4, it is now possible to initialize the readonly properties from a child class, if the visibility allows. And the property is assigned only once.

See Also

PHP Error Messages

PHP Features