Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Final Class Constants

Class constants can be made final, starting with PHP 8.2.

PHP code

<?php

class x {
	final public const A = 1;
}

echo x::A;

?>

Before

PHP Fatal error:  Cannot use 'final' as constant modifier 

After

1

PHP version change

This behavior changed in 8.1.

Error Messages

Extension

© 2023-2026, Damien Seguy - Exakat