Kai345: Schöne quelltexte

Beitrag lesen

[latex]Mae  govannen![/latex]

Grüße,
ich dachte explizit augerufene methoden hätten kein zugriff auf klasseigenschaften bzw. $this wie speicherst du die einrückungstufe?

ohne $this natürlich :D

Ich habe zwar extrem wenig Ahnung von OOP und dieser ganzen Klassen-Thematik (und komme irgendwie nie dazu, dies zu ändern), aber kurz zusammengestümpert:

class A {  
  
   private static $ic = 0;  
  
   public static function A1($a1) {  
     self::$ic = $a1;  
   }  
  
   public static function A2() {  
     echo self::$ic;  
   }  
}  
  
A::A2();  #0  
A::A1(3);  
A::A2();  #3  
A::A2();  #3  
A::A1(7);  
A::A2();  #7  

Cü,

Kai

--
A workaround for an avoidable problem often adds clutter and overhead to the program which
could have been avoided by not creating the problem in the first place.(Garrett Smith/clj)
Foren-Stylesheet Site Selfzeug JS-Lookup
SelfCode: sh:( fo:| ch:? rl:( br:< n4:( ie:{ mo:| va:) js:| de:> zu:) fl:( ss:| ls:?