浏览器访问swoole_http_server时报错
来源:4-4 Swoole - HTTP服务(上)
用户1205655
2018-05-15
,Fatal error: Swoole\Server::__construct(): swoole_server only can be used in PHP CLI mode. in /data/wwwroot/swoole/index.php on line 8
$http = new swoole_http_server("0.0.0.0", 8855);
$http->on('request', function ($request, $response) {
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->start();
写回答
1回答
-
singwa
2018-05-15
您好。您需要在Linux终端里面去执行这个脚本, 然后在从浏览器通过IP+端口号访问才可以
032018-05-17
相似问题