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 {
//
public const C = 3;
}
?>
Related : Final Keyword
Added in PHP 8.1