[php] view plain copy <?php //发布 $redis = new Redis(); $redis->connect('127.0.0.1', 6379); $message='新年快乐'; $ret=$redis->publish('中央广播电台',$message); [php] view plain copy <?php //订阅 ini_set('default_socket_timeout', -1); //不超时 $redis = new Redis(); $redis->connect('127.0.0.1', 6379); $result=$redis->subscribe(array('中央广播电台'), 'callback'); function callback($instance,$channelName,$message){ echo $message; }