Quote:
Originally Posted by Loriel
TStaticVar :|
|
Not exactly what I meant. I meant like the way the static keyword works in C functions. As you probably know, so that variables retain their values even after the function's end, but can't be accessed script-wide, just in that function.
For example:
PHP Code:
function onCreated() {
for (temp.i = 0; temp.i < 10; temp.i++) {
echo(staticTest());
}
}
function staticTest() {
if (temp.staticVar == NULL) temp.staticVar = new TStaticVar();
temp.staticVar.var1++;
return temp.staticVar.var1;
}
outputs this: