3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Dummy { public $input; function __construct($input = array(1,2,3)) { $this->input = $input; } function run($logged) { foreach($this->input as $key=>$value) { echo $value . " " .$logged."\n\n"; if($value == 2 && $logged == false) throw new Exception('hello exception'); array_shift($this->input); } } } function retry(Dummy $dum, $logged = false) { try { echo "dum start run"; $dum->run($logged); echo "dum end run"; } catch(Exception $e) { // solve the exception if(!$logged) $logged = true; echo "dum retry"; retry($dum, $logged); echo "dum end retry"; } } $dum = new Dummy; retry($dum, false);
Output for 5.3.7 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
dum start run1 2 dum retrydum start run2 1 3 1 dum end rundum end retry