<? class classA { var $big_str = ""; function classA(){} function create(){ $obj = new classB(); $this->objects[] = $obj; return $obj; } function echos(){ foreach ($this->objects as $obj ) { $this->big_str .= $obj->get_str() ; } } } class classB { var $some_string =""; function classB(){} function add($str){ $this->some_string .= $str . "|"; } function get_str(){ return $this->some_string; } } $a = new classA(); $b = $a->create(); $b->add("garbage"); $b->add("dummy"); $b->add("some_more"); $c = $a->create(); $c->add("here"); $c->add("some"); $c->add("text"); $a->echos(); #spodziewam się : #garbage|dummy|some_more|here|some|text| #a big_str w classie classA jest pusta ?>
i tutaj musi cos byc z referencjami i kopiami obiektów i zmiennych, jednak nie bardzo wiem co. Próbowałem różnych kombinacji, jednak bezskutecznie.
jeśli ktoś może rzucić troche światła na temat referencji i kopi obiektów
z mountain dzienx
