ResumesInn
Welcome  ,
Interview Questions >> PHP >> How do you call a constructor for a parent class?
Next Question Previous Question

How do you call a constructor for a parent class?



  Joseph Ranjan wrote ...
Way 2 :

class parentClass
{
   function parentClass()
   {
      //...
   }
}

class childClass extends parentClass
{
   function childClass()
   {
      parent::parentClass();
      // ...
   }
}
  Joseph Ranjan wrote ...
Way 1 :

class parentClass
{

   function __construct()
   {
      //...
   }
}

class childClass extends parentClass
{
   function __construct()
   {
      parent::__construct();
      // ...
   }
}


Login to write answer for this question !
Want to place your ads in this website ?
50USD Per Month for single placement. Contact Us
All Rights Reserved . Developed by SJRANJAN