<?php class other { function check() { } } class ext extends main { public function __construct() { $this -> myObjects['other'] -> check(); // nie dziala :/ } public function ble() { } } class main { public $example='Example text'; public function __construct() { $this -> myObjects['other'] = new other(); $this -> myObjects['other'] -> check(); // ok $this -> myObjects['ext'] = new ext(); } } $mainObj = new main(); ?>
Jeżeli stworzony przez obiekt klasy main obiekt klasy other zapisze w tablicy publicznej to obiekt klasy dziedziczącej tą tablice nie widzi jej elementow ;] Dlaczego?
Szukam powiązania tak aby po stworzeniu obiektów 2 klas jeden uzyskał dostęp do drugiego po przez pośrednika - klase main ;]. Próbowałem stworzyć funkcję getIterate w klasie main ;] ale chyba coś pomieszałem bo nie działało... jakieś pomysły?