3v4l.org

run code in 300+ PHP versions simultaneously
<?php class RetriesExceededException extends \Exception {} class Retry { static public function withDelay(callable $fn, $retries, $delay) { return self::execute($fn, $retries, $delay); } static public function immediately(callable $fn, $retries) { return self::execute($fn, $retries); } static private function execute(callable $fn, $retries, $delay = null) { while ($retries) { $retries--; try { return $fn(); } catch (\Exception $e) { if ($retries && $delay) { //do delay } } } throw RetriesExceededException(); } } class Test { public function exception() { throw \Exception(); } } $test = new Test(); try { Retry::immediately(function() use ($test) { $test->exception(); }, 5); } catch (\Exception $e) { var_dump($e); } echo "bar"; //Retry::withDelay($fn, $retries, $delay); //Retry::immediately($fn, $retries);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined function Exception() in /in/FGN0j:44 Stack trace: #0 /in/FGN0j(52): Test->exception() #1 /in/FGN0j(25): {closure}() #2 /in/FGN0j(14): Retry::execute(Object(Closure), 4) #3 /in/FGN0j(52): Retry::immediately(Object(Closure), 5) #4 {main} thrown in /in/FGN0j on line 44
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
63.69 ms | 401 KiB | 8 Q