Pwiedzmy, że mam coś takiego:
Kod
class A {
protected $var;
protected $event;
public function __construct() {
$this->event = new B();
echo $this->event->func();
}
}
class B extends A {
public function func() {
$this->var = "dziala";
return $this->var;
}
}
$obj = new A;
protected $var;
protected $event;
public function __construct() {
$this->event = new B();
echo $this->event->func();
}
}
class B extends A {
public function func() {
$this->var = "dziala";
return $this->var;
}
}
$obj = new A;
Chodzi o to, że chce stworzyć obiekt klasy potomnej w rodzicu, ale ten kod nie działa(nic nie wyświetla).Mógłby ktoś nakierować mnie co robię źle.