phpredis模块安装好了,new redis不起作用

查看:165
本文介绍了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();
?>

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

解决方案

你打印一下$redis->connect()的返回值,看看是不是真的连上了,
如果连上了,就set一个值,在redis-cli里面查看有没有真的设置上。

这篇关于phpredis模块安装好了,new redis不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆