Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> dziedziczenie i get_object_vars, Pobrac tylko metody klasy potomnej
astropanic
post
Post #1





Grupa: Zarejestrowani
Postów: 24
Pomógł: 0
Dołączył: 4.07.2006

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


witam,

  1. <?php
  2. class generic_object{
  3.  
  4.  public $var1;
  5.  public $var2;
  6. }
  7.  
  8. class member extends generic_object{
  9.  
  10.  public $name;
  11.  public $surname;
  12. }
  13. ?>


Jak z poziomu klasy member pobrac same atrybuty tej klasy bez wyswietlania dziedziczonych atrybutow klasy generic_object ?

Pozdrawiam
Go to the top of the page
+Quote Post
msulik
post
Post #2





Grupa: Zarejestrowani
Postów: 83
Pomógł: 0
Dołączył: 31.03.2002
Skąd: Toruń

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


Może
  1. <?php
  2. class member extends generic_object{
  3.  
  4.  public $name;
  5.  public $surname;
  6.  
  7.  public function f()
  8.  {
  9. return array_diff
  10. (
  11.  array_keys(get_object_vars($this)),
  12.  array_keys(get_class_vars(get_parent_class($this)))
  13. );
  14.  }
  15. ?>
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 19:01