$redis = new Redis(); $redis->connect("127.0.0.1","6379"); $redis->publish('tv1', '22222222'); //发布
$channel = 'tv1'; // channel $redis->subscribe(array('channel'.$channel), 'callback'); function callback($redis, $channel, $message) { var_dump($message); exit; }
正确写法
$channel = 'tv1'; // channel $redis->subscribe(array($channel), 'callback'); function callback($redis, $channel, $message) { var_dump($message); exit; }
是我太粗心了,才导致这样的错误。