Home >Backend Development >PHP Tutorial >PHP redis 订阅发布 订阅不成功问题!

PHP redis 订阅发布 订阅不成功问题!

WBOY
WBOYOriginal
2016-06-20 12:50:161866browse

我当前的是可以发布的,但是订阅不行,新手求解!

发布正常
    $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;	}







第一次使用Redis  发布订阅,求大神帮忙看下!



回复讨论(解决方案)

正确写法


    $channel = 'tv1';  // channel    $redis->subscribe(array($channel), 'callback');    function callback($redis, $channel, $message) {      var_dump($message);      exit;    }


 $redis->subscribe(array( 'channel'.$channel), 'callback');

直接去掉 红色部分就行了,搞了二天的问题。

是我太粗心了,才导致这样的错误。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn