Skip to content

Instantly share code, notes, and snippets.

@kobus1998
Created October 22, 2021 12:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kobus1998/67e277ccb1f48bac7f03388b6894efcf to your computer and use it in GitHub Desktop.
Save kobus1998/67e277ccb1f48bac7f03388b6894efcf to your computer and use it in GitHub Desktop.
while, polling
<?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