我已经安装了Redis,Php和Php-Redis,现在当我在程序下面运行该程序时,

<?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();
?>

理想的输出应该是

成功连接到服务器
服务器正在运行:PONG


但是输出iam得到

成功连接到服务器

问题可能在哪里?

最佳答案

您应该更改此:

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

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

因为。运算符用于串联,而+运算符用于加法。

10-07 14:17
查看更多