Re: Re: self:: vs this

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/11/07, M.Sokolewicz <tularis@xxxxxxx> wrote:
statically:
Class Foo {
    static $a = 1;
    static function Bar() {
       self::a++;
    }
}

echo Foo:a;
 >> 1
Foo::Bar(); // will probably throw a warning, not sure of that though
echo Foo:a;
 >> 1 (no change)


I'm not sure I understand what you mean by this.  This code works:
Class Foo {
  static $a = 1;
  static function Bar() {
     self::$a++;
     var_dump(self::$a);
  }

  static function Meh() {
  	self::$a='asdf';
  	var_dump(self::$a);
  }
}

Foo::Bar();
Foo::Bar();
Foo::Bar();
Foo::Meh();

----- output ----
int 2
int 3
int 4
string 'asdf' (length=4)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux