Click to See Complete Forum and Search --> : static variables in static functions


doorman
09-28-2004, 01:48 AM
How do you access static variables from statically called functions.
IE how do i fill in the dots.

class myClass{
static $sv = 1;

function myFunc(){
printf( "sv = %s<BR>", .......sv );
}
}

myClass::myFunc();
myClass::myFunc();

I know that $this is not accepted in static functions and myClass::sv doesn't work either. Is it possible at all? have
I misunderstood some oo principal? any advice would be welcome.

Weedpacket
09-28-2004, 05:34 AM
myClass::$variable works for me

Shrike
09-28-2004, 09:53 AM
class myClass{
static $sv = 1;
function myFunc(){
printf( "sv = %s<BR>", self::$sv );
}
}
myClass::myFunc();

doorman
09-29-2004, 03:50 AM
Thanks guys, I guess I just missed the $ in myClass::$sv