3v4l.org

run code in 200+ 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 $key ." ".$value . " " .$logged."\n\n"; if($key == 2 && $logged == false) throw new Exception('hello exception'); } } } function retry(Dummy $dum, $logged = false) { try { $dum->run($logged); } catch(Exception $e) { // solve the exception if(!$logged) $logged = true; retry($dum, $logged); } } $dum = new Dummy; retry($dum, false);
Output for 5.3.0 - 5.6.30, hhvm-3.10.1 - 3.17.3, 7.0.0 - 7.1.7
0 1 1 2 2 3 0 1 1 1 2 1 2 3 1