php funciton 中的static
网络整理 - 08-30
<?php
function t(){
static $a= 0;
++ $a;
var_dump($a);
}
$i = 3;
while ($i--){
t();
}
结果 1 ,2,3
见手册 $a is initialized only in first call of function and every time the t() function is called it will print the value of $a and increment it.
static的变量初始化只执行一次