3v4l.org

run code in 300+ PHP versions simultaneously
<?php function functionCall4() { if (true or mt_rand(1, 4) === 2) { throw new \Exception('exception'); } } function functionCall3() { functionCall4(); } function functionCall2() { functionCall3(); } function functionCall1() { try { functionCall2(); } catch (\Exception $e) { throw new \RuntimeException($e->getMessage(), $e->getCode(), $e); } } try { functionCall1(); } catch (\RuntimeException $e) { echo 'Exception caught', PHP_EOL; while ($e) { echo 'Trace for ', get_class($e), "\n"; print_r($e->getTrace()); $e = $e->getPrevious(); } }

preferences:
24.22 ms | 404 KiB | 5 Q