in example I want to create a class with constructors, but it should also inherit parent's constructors. I will show you an example.
<?php
class Parent{
public $var1;
public $var2;
public function __construct($var1, $var2){
$this->var1 = $var1;
$this->var2 = $var2;
};
};
class Child1 extends Parent{
public $var3;
public $var4;
public function __construct($var3, $var4){
$this->var3 = $var3;
$this->var4 = $var4;
};
};
class Child2 extends Parent{
public $var5;
public $var6;
public function __construct($var5, $var6){
$this->var5 = $var5;
$this->var6 = $var6;
}
}
$instance = new Child1(var1, var2, var3, var4);
?>
I want to define a new instance of Child1 and Child2 using Parent constructor attributes and their own attributes. Is there a way to do that? Sorry if this seems too easy, I just started learning PHP and concept of OOP. Thanks a lot!