简体   繁体   中英

Php-Redis Issue

I had installed Redis, Php and Php-Redis and now when i run this below program iam getting

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

The ideal output should be

Connection to server sucessfully Server is running: PONG

but the ouput iam get

Connection to server sucessfully

where could be the issue?

You should change this:

echo "Server is running: "+ $redis->ping();

to this:

echo "Server is running: " . $redis->ping();

Because the . operator is for Concatenation, and the + operator is for addition.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM