💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# swoole_http_response::create 构造新的`Http\Response`对象。使用此方法前请务必调用`detach`方法将旧的`$response`对象分离,否则可能会造成对同一个请求发送两次响应内容。 ```php function swoole_http_response::create(int $fd) : swoole_http_response; ``` * 参数为需要绑定的连接`$fd`,调用`Http\Response`对象的`end`与`write`方法时会向此连接发送数据 * 调用成功返回一个新的`Http\Response`对象,调用失败返回`false` > 需要`2.2.0`或更高版本 ```php $http = new swoole_http_server("0.0.0.0", 9501); $http->on('request', function ($req, Swoole\Http\Response $resp) use ($http) { $resp->detach(); $resp2 = Swoole\Http\Response::create($req->fd); $resp2->end("hello world"); }); $http->start(); ```