Skip to content

Instantly share code, notes, and snippets.

@mudge
mudge / test.retry.php
Created July 8, 2013 13:27
A retry function for PHP.
<?php
require_once dirname(__FILE__) . '/../lib/simpletest/autorun.php';
function retry($f, $delay = 10, $retries = 3)
{
try {
return $f();
} catch (Exception $e) {
if ($retries > 0) {
sleep($delay);