Using PHP here, I decided to read through the manual chapter by chapter and learn new things. So now I've discovered static variables, which seem like an awesome concept, but the way I understand it is:
Static variables are set once and only once per load of the script. They can be changed and incremented but not actually re-set. Usually used in functions to set a value and not have to initialize that variable every time the function runs.
<?php
function count2( $inputNum ) {
static $a = $inputNum;
echo $a++; //Echo and then increment.
}
for ( $i = 0; $i < 10; $i++ ) {
count2(50);
}
?>
I'd expect this to start the static $a
var at 50, and increment 11 times. How come I get an error?