这么写set 不好使不知道是为什么
来源:4-9 websocket服务优化
刘小桓
2018-11-24
class hs
{
CONST HOST = “0.0.0.0”;
CONST PORT = 9508;
public $hs = null;
public function __construct()
{
$this->hs = new swoole_http_server('0.0.0.0',9508);
$this->hs->on('request',[$this,"onRequest"]);
$this->hs->start();
}
public function onRequest($request,$response)
{
$response->end("接收数据:".json_encode($request->get));
}
}
$objs = new hs();
$objs->set([
‘enable_static_handler’=>true,
‘document_root’=>"/www/wwwroot/app01/demo/data",
]);
写回答
2回答
-
芭菲雨
2019-01-23
$objs->set这个对象是你自己写的类的对象,不是swoole http服务的对象,这个set应该写在hs类的构造函数里面$this->hs->set([])
012019-01-23 -
singwa
2018-11-25
同学你好具体什么不好使呢?是静态文件?
00
相似问题