Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] czemu ta klasa nie działa
kristoff
post
Post #1





Grupa: Zarejestrowani
Postów: 60
Pomógł: 0
Dołączył: 5.04.2006

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


witam. Proszę o pomoc w wykryciu błędu w tej mojej prostej klasie. Zamiast działać poprawnie wyświetla mi się lista takich komunikatów:
Warning: fread(): supplied argument is not a valid stream resource

Otóż mam plik index.php który zawiera m.in taki fragment kodu:

  1. <?php
  2. include("klasa.php");
  3.  
  4. $angielski = new klasa ("data_en.txt", "random_en.php", 9920, "opis_en", "opis_en_id");
  5. $polski = new klasa ("data_pl.txt", "random_pl.php", 5493, "opis_pl", "opis_pl_id");
  6.  
  7. if($len=='en') {
  8. $angielski->proces();
  9. } else {
  10. $polski->proces();
  11. }
  12. ?>


oraz plik klasa.php którego zawartość to:

  1. <?php
  2. class klasa
  3. {
  4.  
  5. var $data;
  6. var $random;
  7. var $liczba_znakow;
  8. var $opis_len;
  9. var $id_len;
  10.  
  11. function proces () {
  12.  
  13. $fd=fopen("$this->data", "r");
  14. $old=fread($fd, 10);
  15. fclose($fd);
  16. $new=gmdate('d m Y');
  17.  
  18. if($old<>$new) {
  19. $numerek=rand(1, $this->liczba_znakow);
  20. $pobierz=mysql_query("select opis from $this->opis_len where $this->id_len ='$numerek'");
  21. $wiersz_2=mysql_fetch_row($pobierz);
  22. $fr=fopen("$this->random", "w");
  23. fwrite($fr, $wiersz_2[0]);
  24. $fd=fopen("$this->data", "w");
  25. fwrite($fd, $new);
  26. fclose($fd);
  27. $wiersz_2=$wiersz_2[0];
  28. }
  29. else {
  30. $fr=fopen("$this->random", "r");
  31. $wiersz_2=fread($fr, 4000);
  32. }
  33. }
  34. }
  35. ?>


To moja pierwsza klasa jaką utworzyłem no i coś nie działa. Proszę o pomoc
Go to the top of the page
+Quote Post

Posty w temacie


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 Aktualny czas: 21.08.2025 - 10:39