Final Classes/Methods

Classes and methods can be specified as final that will disallow classes to be extended and methods to be overloaded.

<?php
final class foo { function do_something() {} }

class bar extends foo {} // won't work, fatal error

class baz { final function foo() {} function bar() {} }

class foo2 extends baz { function bar() {} } // will work
class foo3 extends baz { function foo() {} } // will not work
?>

Loading ...

Related Results :

  1. Final Classes/Methods
Note :
  • Related Posts are generally User Blog posts.
  • or Other tutorials from other networks of w3clan.com.
  • Any registered user can create related posts based on search term tags.

About the Author