First understand the difference between static variables, declare a function test ()
function num () { $a = 0; Echo $a ; $a+ +;} num (); num (); Num (); // Output
function num () { static$a = 0; Echo $a ; $a+ +;} num (); num (); Num (); // Output 012
From the above you can see the difference between the use of static, static can be repeated when the function is called, the static variable retains the result of the last execution of the function.
Such properties can be used to make interlaced discoloration, etc.
functionGetColor () {Static $colorvalue; if($colorvalue= = ' #FFF ') $colorvalue= ' #000 '; Else $colorvalue= ' #FFF '; return $colorvalue;}Echo"<table border=1>"; for($i= 0;$i<10;$i++) { $bgcolor=GetColor (); Echo"<tr bgcolor=$bgcolor> "; Echo"<td>$i</td> "; Echo"</tr>";}
Http://www.crackedzone.com/php-static-variable-summary.html
Using the static modifier variable inside a function in PHP