![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 8 Pomógł: 0 Dołączył: 16.10.2008 Ostrzeżenie: (0%) ![]() ![]() |
Witam serdecznie!
Panowie lub Panie, mam ogromna prośbe - siędzie nad tym już kilka ładnych godzin i zaraz będe zmuszony poszukać młotka i dać sobie w głowę ... Mam takie KLASY i INTERFEJSY: Kod interface Traversable {} interface Iterator implements Traversable { function current(); function key(); function next(); function rewind(); function valid(); } interface IteratorAggregate implements Traversable { public function getIterator(); } i ... Kod class Collection implements IteratorAggregate { ... public function getIterator() { $this->_checkCallback(); return new CollectionIterator(clone $this); } ... } class CollectionIterator implements Iterator { private $_collection; private $_currIndex = 0; private $_keys; function __construct(Collection $objCol) { $this->_collection = $objCol; $this->_keys = $this->_collection->keys(); } function rewind() { $this->_currIndex = 0; } function valid() { return $this->_currIndex < $this->_collection->length(); } function key() { return $this->_keys[$this->_currIndex]; } function current() { return $this->_collection->getItem($this->_keys[$this->_currIndex]); } function next() { $this->_currIndex++; } } Oczywiście nie wkleiłem całego kodu klasy Collection, sądzę iż nie ma teraz takiej potrzeby. Przykład i implementacja klas/interfejsów biorę z ksiązki PHP5. Zaawansowane programowanie. Wiem, książka ma sporo błędów i głównie właśnie jakieś psikusy zrobione są z interfejsami, choć w tym przypadku mogę się mylić... Potrzebuje pomocy, wywolując program APACHE zwraca: Parse error: syntax error, unexpected T_IMPLEMENTS, expecting '{' in /Applications/MAMP/htdocs/folder/test/folder_base/class/class.Collection.php on line 8 Już nie wiem jak mam sobie z tym poradzić, dlatego jeszcze raz proszę o POMOC! Z góry BARDZO dziękuje wszystkim zaangażowanym w rozwiązaniu problemu Pozdrawiam Paweł - guci0 P.S. Tak na marginesie to, coś słabo działa edytor na forum (BBCODE) Ten post edytował guci0 16.10.2008, 21:01:22 |
|
|
![]() ![]() |
![]() |
Aktualny czas: 15.09.2025 - 05:20 |