请参阅下面的匿名函数,我不想进入下一个for
循环迭代,直到$Connected
为 0
它没有按应有的方式工作...解决此问题的解决方案是什么?
$Client = new Client();
for ($i = 1; $i <= 5; $i++) {
$result = $Client->Action(rand(1,1000));
if ($result->isSuccess()) {
$Connected = 1;
}
// Stay in the loop until 'HangupEvent' received
while ($Connected) {
$Client->EventListener(function (EventMessage $event) {
if ($event instanceof HangupEvent) {
// Received Hangup Event - let terminate this while loop ..
$Connected = 0;
}
});
// If $Connected = 0; then go to next `for` loop iteration
}
}