i'm having a problem with unsetting a static variable in a class.
as an example i have something like this:
class test {
function keepCount($mycount = "") {
static $count = 0;
if($mycount == "") {
return $count;
} else {
return $count += $mycount;
}
}
}
$test = new test();
$test->keepCount(1);
$test->keepCount(1);
$test->keepCount(1);
echo $test->keepCount(); //returns 3
unset($count);
$test->keepCount(1);
echo $test->keepCount(); //returns 5
i need that last one to return 1...
Does this make sense? I have tried unsetting $count inside the class itself (for example each time $mycount == "") but it never gets unset.
Any advice, much appreciated. Thanks for reading!