Quote:
Originally posted by Jawelin
Perfect! It's exactly what I would for that variable! (read above)
This way, such variable should be valued per-user and per-session (I guess when that user's session expires, variable would loose its value... ???):
exactly what I asked before to FireFly...
Well. It doesn't work.... 
Whatever user saw that incremented variable (incremented within a function he runs), that variable is ALWAYS 0 ... 
(note: of course I globalized that variable within that function, even I tried to ++ it outside...)
|
If the variable is defined inside a function (and you want its value preserved when function (but not the script, "function"!) is run again), you have 2 choices:
1- "Global"ize the variable and return it back to script AFTER function ends.
2- Simpler way: define it as a static varible inside the function:
static $a = 1;
Then $a's value will be preserved when same user comes to the same function again.
Of course this doesnt apply if the script is rerun! It's preserved until the script run ends. I think this is already what you wanted?