Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php(5)]Klasy
Eagle
post
Post #1





Grupa: Zarejestrowani
Postów: 170
Pomógł: 14
Dołączył: 16.03.2007

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


Witam (ponownie smile.gif )
Ostatnio postanowiłem przepisać swoje projekty na obiektowe.
Jednak już na samym początku mam problem:

index.php5
  1. <?php
  2. include ('plug.php5');
  3.  
  4.  
  5. $c_name = 'UserInfo';
  6.  
  7. call_user_func(array($c_name, 'main'));
  8. ?>


plug.php5
  1. <?php
  2. class UserInfo
  3. {
  4.  var $imie, $email;
  5.  
  6.  
  7. function __construct()
  8. {
  9. $this->imie='Twoje imię';
  10. $this->email='Twój email';
  11. }
  12.  
  13.  function main()
  14.  {  
  15. echo $this->imie;
  16. echo $this->email;  
  17.  }
  18. }
  19. ?>


Wyskakuje błąd:

Fatal error: Using $this when not in object context in /plug.php5 on line 15
Tylko że nie wiem co jest źle...
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: 19.08.2025 - 21:56