fork download
  1. <?php
  2.  
  3. function retry($times, callable $callback, $sleep = 0)
  4. {
  5. $times--;
  6.  
  7. beginning:
  8. try {
  9. return $callback();
  10. } catch (Exception $e) {
  11. if (! $times) {
  12. throw $e;
  13. }
  14.  
  15. $times--;
  16.  
  17. if ($sleep) {
  18. usleep($sleep * 1000);
  19. }
  20.  
  21. goto beginning;
  22. }
  23. }
  24.  
  25. retry(2, function () {
  26. file_get_contents('https://k...content-available-to-author-only...d.csmpamc');
  27.  
  28. throw new RunTimeException;
  29. });
  30.  
Runtime error #stdin #stdout #stderr 0.01s 52568KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Warning:  file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/EmlHzG/prog.php on line 26
PHP Warning:  file_get_contents(https://k...content-available-to-author-only...d.csmpamc): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/EmlHzG/prog.php on line 26
PHP Warning:  file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/EmlHzG/prog.php on line 26
PHP Warning:  file_get_contents(https://k...content-available-to-author-only...d.csmpamc): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/EmlHzG/prog.php on line 26
PHP Fatal error:  Uncaught exception 'RuntimeException' in /home/EmlHzG/prog.php:28
Stack trace:
#0 /home/EmlHzG/prog.php(9): {closure}()
#1 /home/EmlHzG/prog.php(29): retry(2, Object(Closure))
#2 {main}
  thrown in /home/EmlHzG/prog.php on line 28