swoole static疑惑

<?php
$http = new swoole_http_server("0.0.0.0", 9512);
$http->on("start", function ($server) {
    echo "Swoole http server is started at http://127.0.0.1:9512\n";
});
$http->on("request", function (\swoole_http_request $request, \swoole_http_response $response) {
    static $a= 0;
    $a++;
    $response->write("a:".$a.PHP_EOL);
});
$http->start();

浏览器请求 http://127.0.0.1:9512
第一次输出 a:1
第二次输出 a:3
第三次输出 a:5
第四次输出 a:7

环境:
| PHP | 7.1.15 |
| Swoole | 4.0.0 |
| Laravel Framework | 5.5.26

阅读 3.1k
1 个回答

本来想删除问题,看到声望-1感觉来补个答案。
正常的期望输出是
a:1
a:2
a:3
...

问题出在浏览器请求上,使用chrome请求的,chrome除了正常请求外,还会发送一个favicon.ico的请求。