Sometimes my code breaks and it is out of my control
How would I do the following?
try { //do my stuff } catch { //sleep and try again }
Simply :
function doSomething($params, $try = 1){ try{ //do something return true; } catch(Exception $e){ if($try <5){ sleep(10); //optionnaly log or send notice mail with $e and $try doSomething($params, $try++); } else{ return false; } } }