Nicolase 2019-12-29
<?php
function keep_track() {
static $count = 0;
$count++;
print $count;
}
keep_track();
keep_track();
keep_track();
?>
这将产生以下结果 -
1
2
3
普通变量
<?php
function keep_track() {
static $count = 0;
$count++;
print $count;
}
keep_track();
keep_track();
keep_track();
?>
这将产生以下结果 -
2
2
2