вам нужно вызвать parent :: __ construct () в вашем дочернем конструкте
рабочий код должен быть:
ParentClass.php
<?php
class ParentClass {
public $variable1;
public $variable2 = "Value of variable 2";
public function __construct()
{
$this->variable1 = "Value of variable 1";
}
}
$obj = new ParentClass;
?>
и ChildClass. php
<?php
include "ParentClass.php";
class ChildClass extends ParentClass {
public function __construct()
{
parent::__construct(); // like this
echo $this->variable1;
echo $this->variable2;
}
}
$obj = new ChildClass;
?>
ПОПРОБУЙТЕ это и посмотрите, работает ли оно:)