企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
``` <?php $http = new swoole_http_server("0.0.0.0", 9501); $http->on('request', function($request, $response){ $response->cookie("key1", "value1", time() + 1800); // 设置cookie的键,值,时效 $response->end(json_encode($request->get)); // 浏览器显示url参数的json字符串 }); $http->start(); ``` 设置www目录为根目录: ``` <?php $http = new swoole_http_server("0.0.0.0", 9501); $http->set( [ 'enable_static_handler' => true, 'document_root' => '/home/wwwroot/target.testdomain.solutions/www', ] ); $http->on('request', function($request, $response){ // $response->cookie("key1", "value1", time() + 1800); // 设置cookie的键,值,时效 // $response->end(json_encode($request->get)); // 浏览器显示url参数的json字符串 $response->end("index"); }); $http->start(); ```