Final method: A final method is a method that cannot be overridden. To declare a method as final, you need to prefix the function name with the ‘final’ keyword. eg: class Teacher { final public function attendance() { echo "Teacher attendance called"; } } class Student extends Teacher { //this will cause Compile error public function attendance() { echo "Student attendance called"; } } $st = new Student(); $st->attendance(); Results in Fatal error: Cannot override final method Teacher::attendance() final class: A final class is a class that cannot be extended. To declare a class as final, you need to prefix the ‘class’ keyword with ‘final’. Example below. final class Teacher { public function attendance() { echo "Teacher attendance called"; } } //this will cause Compile error class Studen...
Coding Cheatsheets - Learn web development code and tutorials for Software developers which will helps you in project. Get help on JavaScript, PHP, XML, and more.