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 Keyword

The final keyword prevents child classes from overriding a method or a constant by prefixing the definition with final.

The final keyword cannot be used with the private keyword: a private method is not visible in the child classes, and can’t also be redefined.

<?php

    final class Elephpant {
        final const HABITAT = 1;

        final function method() { }
    }

?>

Documentation

See Also