Skip to content

Instantly share code, notes, and snippets.

@shawnlindstrom shawnlindstrom/retry.php

Last active Nov 27, 2018
What would you like to do?
PHP Try/Retry on Exception
* Basic structure for retrying when an exception is thrown in a try/catch block.
* This example fails through three retries simply to illustrate the behavior.
$retries = 3;
for ($try = 0; $try < $retries; $try++) {
try {
throw new \Exception('bad mojo');
} catch (\Exception $e) {
var_dump('failed ' . $try);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.