Page 1 of 1

Initialise a variable once?

Posted: Sun Apr 12, 2009 7:28 pm
by phpnitemare
hello,

I am trying to set a variable to 0 when the webpage first loads. Doing this in my index.php currently means the variable would contantly get reset changing the pointer variable back to 0. Even using the if statement below causes the same problem as without establishing pointzero to 0 the variable will not be initialised however the if statement will always be true. How can I build it so that pointer is only set to 0 once upon first website load?


$_SESSION["pointzero"] = 0;
if($_SESSION["pointzero"] == 0) {
$pointer = 0;
$_SESSION["pointer"] = $pointer;
$_SESSION["pointzero"] = 1;
}

Re: Initialise a variable once?

Posted: Sun Apr 12, 2009 8:27 pm
by requinix
What was wrong with your other thread?

One thread per question. Not two. Not three.