开发者社区> 问答> 正文

关于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 2756 0
1 条回答
写回答
取消 提交回答
  • 你打印一下$redis->connect()的返回值,看看是不是真的连上了,
    如果连上了,就set一个值,在redis-cli里面查看有没有真的设置上。

    2019-07-17 18:55:20
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载