Swoole 使用on()绑定事件报错
错误Argument 2 passed to Swoole\Server::on() must be callable, array given
swoole使用on()绑定事件报错Argument 2 passed to Swoole\Server::on() must be callable, array given
查阅文档
swoole支持四种方式绑定回调
四种设置回调函数的方式
我的解决办法
我这里是因为绑定的回调函数不是public权限,改成public就行了
public function pokerOpen($serv, $frame)$this->serv->on('start', ([$this, 'pokerOpen']));
本作品采用《CC 协议》,转载必须注明作者和本文链接
关于 LearnKu
Argument 2 passed to Swoole\Server::on () must be callable, array given 这个错误很清楚 参数是一个callable类型 你传入了一个array 所以就报错了