$http = new swoole_http_server("0.0.0.0", 9501);
$http->on("request", function ($request, $response) {
static $i;
$i++;
var_dump($i);
$response->end($i);
});
$http->start();
你會發現 常駐進程后靜態變量不會釋放,每個用戶訪問一次,就加一次。
[root@localhost swoole]# php time.php ^[[15~int(1) int(2) int(3) int(4) int(5) int(6) int(7) int(8) int(9) int(10) int(11) int(12)
