Home :: International :: Manuals :: Howto :: FAQ :: Man Pages :: Email Login

 
 

 

Final Keyword

PHP 5 introduces the final keyword, which prevents child classes from overriding a method or variable by prefixing the definition with final.

Beispiel 18-17. 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()
?>
 
 
 
 
Google
  Web Linuxinfor   
 

Home :: Copyright :: Privacy :: Credits :: Get a free Linuxinfor Email Account

Document on this page is part of "PHP Handbuch". See Index Page for more info about Authorship and Copyright.

1999-2009 Linuxinfor.com. No rights reserved.