Reputation: 3
I need to call the constructor of the following class Foto
class Foto extends Galerie
{
function __construct($a,$b)
{ }
}
via its child class. Something like:
class Album extends Foto
{
function __construct($a,$b)
{ return $this->Foto[__construct] }
}
Any ideas? Hope you'll get my point.
Upvotes: 0
Views: 101
Reputation: 72729
You can call the parent constructor by doing:
parent::__construct($a, $b);
Now that we got that out of the way:
Please give your variables decent names. $a
and $b
tells nothing. Also I'm really wondering whether you should really extend those classes. Read about the Liskov substitution principle.
Upvotes: 1
Reputation: 568
parent::__construct($a,$b)
Is what you're looking for. You can also call parent class methods utilizing the same keyword.
Upvotes: 4