Home > Backend Development > PHP Tutorial > phpredis模块安装好了,new redis不起作用

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

WBOY
Release: 2016-06-06 20:16:36
Original
1304 people have browsed it

<code><?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();
?></code>
Copy after login
Copy after login

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

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

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

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

回复内容:

<code><?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();
?></code>
Copy after login
Copy after login

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

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

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

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

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template