Created
October 22, 2021 12:45
-
-
Save kobus1998/67e277ccb1f48bac7f03388b6894efcf to your computer and use it in GitHub Desktop.
while, polling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$i = 0; | |
$var = function () use (&$i) { | |
$i++; | |
return $i; | |
}; | |
$iSeconds = 0; | |
while(($i2 = $var()) < 4 && $iSeconds <= 4) { | |
echo "polling {$i2} {$iSeconds}!!!\n"; | |
$iSeconds++; | |
sleep(1); | |
} | |
if ($i2 != 3) { | |
echo "done polling, task complete\n"; | |
} else { | |
echo "done polling, task timed-out\n"; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment