static使用

function test(){

    static $a=0;

    $a++;

   echo $a;

}

test();

test();

结果是1,2

因为同名函数调用的是同一个静态变量,所以第二次调用test(),就不走static $a

猜你喜欢

转载自blog.csdn.net/qq_37779709/article/details/80877484