Created a plugin at the parse_templates hook. Every time the screen is refreshed it keeps echoing '0', and does not increment as expected - 0, 1, 2, 3, 4, 5, 6...
Help?
function Test()
{
static $a = 0;
$a++;
echo $a;
}
Test();
--------------- Added [DATE]1222142702[/DATE] at [TIME]1222142702[/TIME] ---------------
Quote:
Originally Posted by Abomination
Created a plugin at the parse_templates hook. Every time the screen is refreshed it keeps echoing '0', and does not increment as expected - 0, 1, 2, 3, 4, 5, 6...
Help?
function Test()
{
static $a = 0;
$a++;
echo $a;
}
Test();
|
Think I found the problem.
function Test()
{
static $a = 0;
$a++;
echo $a;
}
Test();
Test();
Test();
Test();
Will indeed output 1, 2, 3, 4 etc.
When a page is refreshed it re-initializes the variable "a" to 0. Seems static variables could be useful but not for what I am trying to accomplish, "session variable" is what might work best. More information over here:
https://vborg.vbsupport.ru/showthrea...ble#post255557
--------------- Added [DATE]1222142845[/DATE] at [TIME]1222142845[/TIME] ---------------
The "Auto-Merged DoublePost " feature of vBulletin.org is interesting, not sure that is something I can appreciate though.