swoole http server 信息

<?php
$http = new SwooleHttpServer('0.0.0.0', 9501);

$http->on('request', function ($request, $response) {
    var_dump($request->server);
    $response->header("Content-Type", "text/html; charset=utf-8");
    $response->end("<h1>Hello Swoole. #".rand(1000, 9999)."</h1>");
});

$http->start();

访问:http://127.0.0.1:9501/

array(10) {
  ["request_method"]=> //请求方法
  string(3) "GET"
  ["request_uri"]=> //url
  string(1) "/"
  ["path_info"]=> //URL路径
  string(1) "/"
  ["request_time"]=> //请求事件
  int(1605785858)
  ["request_time_float"]=> //浮动
  float(1605785858.9703)
  ["server_protocol"]=>  //服务器协议
  string(8) "HTTP/1.1"
  ["server_port"]=> //服务器端口
  int(9501)
  ["remote_port"]=>   //远程端口
  int(62561)
  ["remote_addr"]=>
  string(9) "127.0.0.1"
  ["master_time"]=>
  int(1605785858)
}
原文地址:https://www.cnblogs.com/buxiangxin/p/14007513.html