Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> __CLASS__
UDAT
post
Post #1





Grupa: Zarejestrowani
Postów: 442
Pomógł: 0
Dołączył: 27.12.2005

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


Jak pobrać nazwę klasy z obiektu??
Niestety __CLASS__ nie działa, gdyż w momencie:
  1. <?php
  2.  
  3. class foo
  4. {
  5.    function getClass()
  6.    {
  7.          return __CLASS__;
  8.     }
  9.     // coś tam
  10. }
  11.  
  12. class foo2 extends foo
  13. {
  14. //coś tam
  15. }
  16.  
  17. ob=new foo2;
  18. echo ob->getClass(); 
  19.  
  20. ?>

wypisuje foo (IMG:http://forum.php.pl/style_emoticons/default/sad.gif) a powinno foo2

Ten post edytował UDAT 28.12.2005, 10:58:08
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
ActivePlayer
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 1 224
Pomógł: 40
Dołączył: 6.07.2004
Skąd: Wuppertal

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


  1. <?php
  2. class foo
  3. {
  4. function make(){
  5. $this->makeSth();
  6. $this->makeSth1();
  7. $this->makeSth2();
  8. }
  9. // coś tam
  10. function makeSth(){
  11. return false;
  12. }
  13.  
  14. function makeSth1(){
  15. return false;
  16. }
  17.  
  18. function makeSth2(){
  19. return false;
  20. }
  21.  
  22. }
  23.  
  24. class foo2 extends foo
  25. {
  26. //coś tam
  27. function makeSth(){
  28. echo 'makesth';
  29. }
  30.  
  31. function makeSth1(){
  32. echo 'makesth1';
  33. }
  34.  
  35. function makeSth2(){
  36. echo 'makesth2';
  37. }
  38.  
  39. }
  40.  
  41. $ob=new foo2();
  42. echo foo2->make(); 
  43. ?>

moze tak ?(IMG:http://forum.php.pl/style_emoticons/default/smile.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 Aktualny czas: 16.10.2025 - 13:37