How do you call a constructor for a parent class?

Use the parent keyword like so:

class parentClass
{
   // magic call to constructor -> __construct
   function __construct()
   {
      //...
   }
}

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

OR

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

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

EDIT: You can add parameters to your constructors and parent calls as needed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.