PHP 5 introduces the final keyword, which prevents child classes from
overriding a method by prefixing the definition with final. If the class
itself is being defined final then it cannot be extended.
Example 19-27. Final methods example
<?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() ?>
Example 19-28. Final class example
<?php final class BaseClass { public function test() { echo "BaseClass::test() called\n"; }
// Here it doesn't matter if you specify the function as final or not final public function moreTesting() { echo "BaseClass::moreTesting() called\n"; } }
class ChildClass extends BaseClass { } // Results in Fatal error: Class ChildClass may not inherit from final class (BaseClass) ?>
Php language.oop5.final Function syntax tag
language.oop5.final php code on this is provided for your study purpose, it will guide you to know how create and design a website using php. use it to practice and train your self online
Php language.oop5.final syntax tutorial
php tutorial guide and code design are for easy learning and programming. The code practice section provided at the top is for practising of this syntax. Use the code section up to practice your php programming online. Learning php is very easy, all you need is to use the examples on this site and practice them to perfect your skills.