1 Star 0 Fork 1

1111听听风儿的声音/swoole

forked from daydayupup/swoole 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
http_server.php 843 Bytes
一键复制 编辑 原始数据 按行查看 历史
daydayupup 提交于 2021-11-13 19:05 +08:00 . URL 路由
<?php
$http = new Swoole\Http\Server('0.0.0.0', 9503);
$http->on('Request', function ($request, $response) {
if (($request->server['path_info'] == '/favicon.ico') || ($request->server['request_uri'] == '/favicon.ico')) {
$response->end();
return ;
}
var_dump($request->get, $request->post);
$response->header('Content-Type', 'text/html; charset=utf-8');
$response->end('<h1>hello swoole.#' . rand(1000, 9999) . '</h1>');
});
//如下代码在浏览器输入http://127.0.0.1:9501/test/index/?a=1报错
//$http->on('Request', function ($request, $response) {
// list($controller, $action) = explode('/', trim($request->server['request_uri'], '/'));
// //根据 $controller, $action 映射到不同的控制器类和方法
// (new $controller)->$action($request, $response);
//});
$http->start();
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/nbvc/swoole.git
git@gitee.com:nbvc/swoole.git
nbvc
swoole
swoole
master

搜索帮助