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 协议》,转载必须注明作者和本文链接
讨论数量: 1

Argument 2 passed to Swoole\Server::on () must be callable, array given 这个错误很清楚 参数是一个callable类型 你传入了一个array 所以就报错了

3年前 评论
zmxyzmxy1234 (楼主) 3年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!