php new redis错误,执行redis命令的时候报了一堆错误。。不明白是什么原因。。

RT,源码大体是这样,

$redis = new Redis();

$redis->connect('127.0.0.1', 6379);

if($redis) {echo "Connection to server sucessfully\n";}

//check whether server is running or not

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

echo $redis->get("data1")."\n";

$task1 = new Worker();

$task1->name = 'device1';

$task1->onWorkerStart = function($task)

{

$time_interval = 3;

Timer::add($time_interval, function()

{

echo $redis->get("data1");

});

};

CMD里提示的内容是这样,

G:\workerman-for-win-master\workerman-for-win-master>php Applications\example\device1.php

Connection to server sucessfully

Server is running: +PONG

1000

----------------------- WORKERMAN -----------------------------

Workerman version:3.2.5 PHP version:7.0.3

------------------------ WORKERS -------------------------------

worker listen processes status

device1 none 1

-----------------------------------------------------------------------

Press Ctrl-C to quit. Start success.

PHP Notice: Undefined variable: redis in G:\workerman-for-win-master\workerman-for-win-master\Applications\example\device1.php on line 27

Notice: Undefined variable: redis in G:\workerman-for-win-master\workerman-for-win-master\Applications\example\device1.php on line 27

PHP Fatal error: Uncaught Error: Call to a member function get() on unknown in G:\workerman-for-win-master\workerman-for-win-master\Applications\example\device1.php:27

Stack trace:

#0 : {closure}()

#1 G:\workerman-for-win-master\workerman-for-win-master\Events\Select.php(187): call_user_func_array(Object(Closure), Array)

#2 G:\workerman-for-win-master\workerman-for-win-master\Events\Select.php(226): Workerman\Events\Select->tick()

#3 G:\workerman-for-win-master\workerman-for-win-master\Worker.php(740): Workerman\Events\Select->loop()

#4 G:\workerman-for-win-master\workerman-for-win-master\Worker.php(428): Workerman\Worker->run()

#5 G:\workerman-for-win-master\workerman-for-win-master\Worker.php(345): Workerman\Worker::runAllWorkers()

#6 G:\workerman-for-win-master\workerman-for-win-master\Applications\example\device1.php(32): Workerman\Worker::runAll()

#7 {main}

thrown in G:\workerman-for-win-master\workerman-for-win-master\Applications\example\device1.php on line 27

查了一下相关的问题,感觉也不像CLI类加载失败的情况,毕竟在Worker上面的内容都正常,连接redis也正常,到了worker的timer里就出问题了。。

求解答。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值