• home
  • Email: trainings@synapseindia.careers

Blogs

back

Abstract Class In PHP

Sep 30, 2015

The class whose object cannot be created,if we try to do so then it will generate an error. The child classes which inherits the property of abstract base class must define all the methods which has been declared as abstract. Let us understand it through a program: <?php abstract class demo{ public function disp(){ echo "Inside the parent class<br/>"; } } class xy extends demo{ public function disp(){ echo "Inside the child class<br/>"; } } class synapse extends demo{ //we have not declared any method of this class } $t=new xy(); echo "<b>Calling from the child class xy:</b><br/>"; $t->disp(); echo "<b>Calling from the child class synapse:</b><br/>"; $ob=new synapse(); $ob->disp(); ?>

SynapseIndia (CEO: Shamit Khemka)