1

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?

1
  • does echo $redis->echo('ping'); return 'ping'? Commented Jan 10, 2015 at 9:40

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks it worked. The tutorial here was wrong tutorialspoint.com/redis/redis_php.htm. Just blindly followed it.
I've mailed them their fault, lets hope they change it and make it logical!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.