Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> statyczne i dziedziczenie
g00fy
post 26.07.2005, 21:44:43
Post #1





Grupa: Zarejestrowani
Postów: 22
Pomógł: 0
Dołączył: 23.11.2004

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


mam takie pytanie , bo nie mam przy sobie zadnego serwa z php (PALM)
czy tworzac

  1. <?php
  2.  
  3. class Module{
  4. static $modules = array();
  5. public static function _get(){}//do pozniejszej edycji
  6. public static function _set(){}//do pozniejszej edycji
  7. }
  8. class Core extends Module{}//do pozniejszej edycji
  9. class Shop extends Module()//do pozniejszej edycji
  10.  
  11. ?>

i pytanie brzmi , czy metody _get i _set benda odwolywac sie do tej samej statycznej $modules , ... chodzi mi o to by Core , Shop i Module korzystalo z Module::$modules , czy jest to mozliwe (czy to tak dziala czy nie)...
cos pokreacilem sorx , moze ktos sie domysli
Go to the top of the page
+Quote Post
crash
post 26.07.2005, 22:14:14
Post #2





Grupa: Przyjaciele php.pl
Postów: 2 196
Pomógł: 2
Dołączył: 17.01.2004
Skąd: Sosnowiec

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


  1. <?php
  2. class Module
  3. {
  4.  static $modules = array();
  5.  
  6.  public static function _get( $name )
  7.  {
  8. if( isset( self::$modules[ $name ] ) )
  9. {
  10.  return self::$modules[ $name ];
  11. }
  12.  }
  13.  
  14.  public static function _set( $name, $value )
  15.  {
  16. self::$modules[ $name ] = $valule;
  17.  }
  18. }
  19.  
  20. class Core extends Module
  21. {
  22. }
  23.  
  24. class Shop extends Module
  25. {
  26. }
  27.  
  28. $core = new Core;
  29. $shop = new Shop;
  30.  
  31. $core->test = 'Testujemy';
  32.  
  33. echo 'Core: '.$core->test.'<br/>Shop: '.$shop->test;
  34. ?>

O to Ci chodzilo? Jeśli tak to odpowiedź brzmi: nie smile.gif


--------------------
Go to the top of the page
+Quote Post
Bora
post 2.08.2005, 13:09:57
Post #3





Grupa: Zarejestrowani
Postów: 270
Pomógł: 0
Dołączył: 15.06.2003

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


da sie.
napisalem juz odpowiedz pare dni temu alepomylilem tematy:
http://forum.php.pl/index.php?act=ST&f=49&...=0&#entry190804
moze ktos z moderatorow przeniesie wowczas prosze o usuniecie tego postu.
Go to the top of the page
+Quote Post

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: 23.06.2025 - 09:21