PHP program to demonstrate the final keyword
<?php
//PHP program to demonstrate the final keyword.
class ParentClass
{
final public function Method()
{
printf("Parent::Method() called<br>");
}
}
class Child extends ParentClass
{
final public function Method()
{
printf("Child::Method() called<br>");
}
}
$ChildObj = new Child();
$ChildObj->Method();
?>
Output
PHP Fatal error: Cannot override final method ParentClass::Method()
in /home/main.php on line 16
