Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Obiekt i konwersja na string
shine
post 31.03.2008, 21:13:13
Post #1





Grupa: Zarejestrowani
Postów: 78
Pomógł: 5
Dołączył: 15.04.2006

Ostrzeżenie: (10%)
X----


Mam taki kod:

  1. <?php
  2.  
  3. class szablon {
  4.  
  5.  
  6. public $nazwa_gry;
  7. public $nazwa;
  8.  
  9. public function ustaw_nazwe($nazwa) {
  10. $this -> nazwa_gry = $nazwa;
  11. return $this -> nazwa_gry;
  12. }
  13. }
  14.  
  15. $obiekt = new szablon;
  16.  
  17. echo 'Nazwa gry to' . $obiekt -> ustaw_nazwe('Gra - wojownicy');
  18.  
  19. class naglowki {
  20.  
  21. public $ktory;
  22. public $gdzie;
  23. public $wynik;
  24. public $page_content;
  25.  
  26.  
  27. public function ustaw($ktory,$gdzie)
  28. {
  29. $this -> ktory = $ktory;
  30. $this -> gdzie = $gdzie;
  31.  
  32. $this -> page_content = file_get_contents($gdzie);
  33. $this -> wynik = str_replace($this -> ktory, file_get_contents("$this -> gdzie"), $this->page_content);
  34.  
  35. //echo $this -> wynik;
  36. }
  37.  
  38. }
  39.  
  40.  
  41.  
  42. //$page_content = file_get_contents("pages/main.html");
  43.  
  44. $czesc = new naglowki;
  45.  
  46. $czesc -> ustaw("!!HEADER!!", 'design/header.html');
  47.  
  48. /*
  49. $page_content = str_replace("GORA", file_get_contents("design/common_tags.html"),$page_content);
  50.  
  51. $page_content = str_replace("NAGLOWEK", file_get_contents("design/header.html"),$page_content);
  52. $page_content = str_replace("LEWA", file_get_contents("design/left_column.html"),$page_content);
  53. $page_content = str_replace("PRAWA", file_get_contents("design/right_column.html"),$page_content);
  54. $page_content = str_replace("STOPKA", file_get_contents("design/footer.html"),$page_content);
  55.  
  56. $page_content = str_replace("DOL", $nazwa_gry,$page_content);
  57. echo $page_content;
  58. */
  59.  
  60.  
  61.  
  62. ?>


dostaje blad:
Cytat
Catchable fatal error: Object of class naglowki could not be converted to string in C:\xampplite\htdocs\gra\index.php on line 33


Probowalem na rozne sposoby, ale nie mam pojecia dlaczego taki blad sad.gif
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 Wersja Lo-Fi Aktualny czas: 14.08.2025 - 02:10