Powiedzmy że mam taką metodę klasy "imgfile" :
public function isExistFile($imgid) { $this->filelink .= $imgid.'.jpg'; { return $this->filelink; } else { return $this->filelink; } }
Teraz w innej klasie wywołuję tą metodę :
$upload = new imgfile; while ($row = $wynik->fetch_assoc()) { if($akcja = $upload->isExistFile($row['imgid'])) { } else { ... ... } }
$row['imgid'] - zawiera kolejne id obrazków np. 1,2,3,4
Po odpaleniu :
Daje mi takie coś :
../uimages/28.jpg../uimages/28.jpg29.jpg../uimages/28.jpg29.jpg30.jpg../uimages/28.jpg29.jpg30.jpg31.jpg
Zamiast zwrócić :
../uimages/28.jpg../uimages/29.jpg../uimages/30.jpg
Gdy w pętle 'while' dodam za każdym razem - $upload = new imgfile to problem się rozwiązuje (ale po co na nowo tworzyć obiekt klasy). Dlaczego metoda zwraca sumę kolejnych $row['imgid'] ?