<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>final methods</title>
</head>

<body text="#000080" bgcolor="#FDE6C1">
class_final_method.php
<?php
class BaseClass {
public function test() {
echo "BaseClass::test() called\n";
}

final public function moreTesting() {
echo "BaseClass::moreTesting() called\n";
}
}

class ChildClass extends BaseClass {
// public function moreTesting() {
// echo "ChildClass::moreTesting() called\n";
// }
}
// Results in Fatal error: Cannot override final method BaseClass::moreTesting()

?>
<br> When and how to use final method<br>
<?php
class A {
public function someMethod() { echo "<br>do something <br>"; }
}
class B extends A {
public final function someMethod() { echo"do something else as a final option"; } //override parent function
}
$c = new A();
$c->someMethod();
$c1= new B();
$c1->someMethod(); //call the override function in chield class
?>

</body>
</html>