开发者社区 问答 正文

关于phpredis模块安装好了,new redis不起作用 问题

<?php
   //Connecting to Redis server on localhost
   $redis = new Redis();
   $redis->connect('localhost', 6379);
   echo "Connection to server sucessfully";
   //check whether server is running or not
   echo "Server is running: "+ $redis->ping();
?>

screenshothttps://segmentfault.com/img/bVtcrZ/view

screenshothttps://segmentfault.com/img/bVtcr1/view

screenshothttps://segmentfault.com/img/bVtcsa/view

上面是我的代码和运行后的截图,我不明白是什么原因导致的,拜托各位指点指点了。

展开
收起
爵霸 2016-03-09 09:20:14 2916 分享 版权
1 条回答
写回答
取消 提交回答
  • 你打印一下$redis->connect()的返回值,看看是不是真的连上了,
    如果连上了,就set一个值,在redis-cli里面查看有没有真的设置上。

    2019-07-17 18:55:20
    赞同 展开评论