Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Dziwny błąd
kajzur
post
Post #1





Grupa: Zarejestrowani
Postów: 385
Pomógł: 26
Dołączył: 22.03.2008
Skąd: TM

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


Catchable fatal error: Argument 2 passed to goods::addGoods() must be an instance of integer, integer given, called in C:\Program Files\WebServ\httpd-users\all\index.php on line 16 and defined in C:\Program Files\WebServ\httpd-users\all\class.php on line 140

Dostaje taki błąd.. Dziwny ponieważ można przetłumaczyć go jakos: argument drugi podany do goods::addGoods() musi być typem integer, integer podany, w C:\Program Files\WebServ\httpd-users\all\index.php on line 16 and defined in C:\Program Files\WebServ\httpd-users\all\class.php on line 140

O co mu chodzi jeśli kurde dałem mu integer a w deklaracji klasy również jest integer:
  1. <?php
  2. public function addGoods($nazwa, integer $kategoria, $opis, double $cena, integer $ilosc)
  3. ?>
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
wookieb
post
Post #2





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




http://pl.php.net/oop5.typehinting
Cytat
Functions are now able to force parameters to be objects (by specifying the name of the class in the function prototype) or arrays (since PHP 5.1).


U ciebie coś takiego oznacza że parametr musi być egzemplarzem klasy integer. A twój parametr jest zmienna typu integer a nie egzemplarzem klasy.
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 31.12.2025 - 18:09