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 doSomething() { throw new \Exception(); } } $test = new Test(); try { Retry::immediately(function() use ($test) { $test->doSomething(); }, 5); } catch (\Exception $e) { var_dump($e); } //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 RetriesExceededException() in /in/LIJFZ:36 Stack trace: #0 /in/LIJFZ(14): Retry::execute(Object(Closure), 0) #1 /in/LIJFZ(52): Retry::immediately(Object(Closure), 5) #2 {main} thrown in /in/LIJFZ on line 36
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:
33.4 ms | 401 KiB | 8 Q