Final Class Constants¶
Using the final option with class constants, the constant cannot be redefined by a child class. It is not possible to give it a new value or visibility.
It yields a fatal error: y::x cannot override final constant.
<?php
class X {
final public const F = 1;
public const C = 2;
}
class Y extends X {
// this is an error
public const C = 3;
}
?>
Related : Final Keyword
Added in PHP 8.1