$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)
原文:https://www.cnblogs.com/brady-wang/p/13352927.html