Final Methods in PHP5
The function declared as final can be used with in subclass but
like other function we cannot override the function declared as final.
<?php
class A {
final function print_all() {
echo ‘this is class A’;
}
}
class B extends A {
function print_all() {
echo ‘this is class B’;
}
}
$obj = new B();
$obj->print_all();
?>
Executing the above example results in the following error:
Fatal error: Cannot override final method A::print_all() in E:/work/test_final.php
