Class var not retaining values
| From: | Bob | Date: | Mon, 21 May 2001 21:58:06 +0000 |
| Subject: | Class var not retaining values | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-53782@lists.php.net to get a copy of this message | ||
I have a class defined with a var $reasons that I will use as an array. The
code to add to it is:
function AddReason($score, $reason, $id)
{
static $index = 0;
$this->reasons[$index] = "$score|$reason|$id";
for ($i = 0; $i < $index; $i++)
{
$out = $this->reasons[$i];
echo "$out...";
}
$index++;
return $score;
}
However, every time I call it, the value stored in the reasons array seems
to disappear, and the array holds no data. It seems to be behaving like a
local variable, even though it is in a class. Any suggestions would be
greatly appreciated.
Thanks