Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Problem Parse error: parse error, expecting, Parse error: parse error, expecting
franzmauler
post 25.03.2009, 18:31:55
Post #1





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 25.06.2007

Ostrzeżenie: (0%)
-----


Witam wszystkich właśnie zabrałem się za przerabianie książki Php i Mysql - Tworzenie stron www i w rozdziale 6 mam problem:


  1. Parse error: parse error, expecting `'{'' in c:\usr\krasnal\www\rozdzial_06\iterator.php on line 2



Kod iterator.php wygląda tak:


  1. <?php
  2. class IteratorObiektu implements Iterator {
  3.  
  4.   private $ob;
  5.   private $ile;
  6.   private $biezacyIndeks;
  7.  
  8.   function __construct($ob)
  9.   {
  10.     $this->ob = $ob;
  11.     $this->ile = count($this->ob->dane);
  12.   }
  13.   function rewind()
  14.   {
  15.     $this->biezacyIndeks = 0;
  16.   }
  17.   function valid()
  18.   {
  19.     return $this->biezacyIndeks < $this->ile;
  20.   }
  21.   function key()
  22.   {
  23.     return $this->biezacyIndeks;
  24.   }
  25.   function current()
  26.   {
  27.     return $this->ob->dane[$this->biezacyIndeks];
  28.   }
  29.   function next()
  30.   {
  31.     $this->biezacyIndeks++;
  32.   }
  33. }
  34.  
  35. class Obiekt implements IteratorAggregate
  36. {
  37.  public $dane = array();
  38.  
  39.  function __construct($wejscie)
  40.  {
  41.    $this->dane = $wejscie;
  42.  }
  43.  
  44.  function getIterator()
  45.  {
  46.    return new IteratorObiektu($this);
  47.  }
  48. }
  49.  
  50. $mojObiekt = new Obiekt(array(2, 4, 6, 8, 10));
  51.  
  52. $mojIterator = $mojObiekt->getIterator();
  53. for($mojIterator->rewind(); $mojIterator->valid(); $mojIterator->next())
  54. {
  55.  $klucz = $mojIterator->key();
  56.  $wartosc = $mojIterator->current();
  57.  echo "$klucz => $wartosc <br />";
  58. }
  59. ?>


Ten post edytował franzmauler 25.03.2009, 18:33:23
Go to the top of the page
+Quote Post
nospor
post 25.03.2009, 19:22:41
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




czyzbys odpalal to na php4?


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
franzmauler
post 26.03.2009, 13:57:44
Post #3





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 25.06.2007

Ostrzeżenie: (0%)
-----


Raczej tak a czemu pytasz??
Go to the top of the page
+Quote Post
nospor
post 26.03.2009, 13:58:18
Post #4





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




bo kod jest na php5....


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
franzmauler
post 26.03.2009, 14:11:44
Post #5





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 25.06.2007

Ostrzeżenie: (0%)
-----


Oki wielkie dzięki już krasnala w 5tce uruchomiłem śmiga wszystko.

Dzięki wielkie dobry człowieku:)


Pozdrawiam
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 13.08.2025 - 21:56