Tuesday, August 5, 2014

Abstract classes in PHP

Related Links

  • http://php.net/manual/en/language.oop5.interfaces.php
  • http://www.techflirt.com/tutorials/oop-in-php/abstract-classes-interface.html

What is class abstraction?

  • PHP 5 introduces abstract classes and methods.
  • Usually abstract class are also known as base class.
  • Abstract classes are those classes which can not be directly initialized. Or in other word we can say that you can not create object of abstract classes.
  • Any class that contains at least one abstract method must also be abstract.
  • Abstract classes always created for inheritance purpose. You can only inherit abstract class in your child class.
  • It can only act as parent class of any normal class. You can use abstract class in class hierarchy. Mean one abstract class can inherit another abstract class also.
  • A protected abstract function can be implemented as either protected or public but not private.

No comments:

Post a Comment