Time::del 未什么没用呢
Timer::add(1, function () {
if ((new Game())->insertNewNumber()) {
// 倒计时
$timer_id = Timer::add(1, function () use(&$timer_id) {
try {
$res = (new Game())->countdown();
if ($res) {
echo "----------新一轮倒计时开始--------\r\n";
echo '倒计时'.$timer_id;
if ($res['type'] == 'close') {
Timer::del($timer_id);
echo '倒计时'.$timer_id.'关闭';
}
if ($res['type'] == 'is_f') {
(new Game())->fp();
}
if ($res['type'] == 'is_q') {
(new Game())->qz();
}
}
} catch (\Exception $e) {
Timer::del($timer_id);
}
});
}
});
把最外层定时器屏蔽,开一个进程来跑看看,你这里逻辑感觉不怎么对。
逻辑不对 已解决