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 ."\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.0.0 - 7.1.0
dum start run1 2 dum retrydum start run2 3 dum end rundum end retry
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/V4e3J on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/V4e3J on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/V4e3J on line 4
Process exited with code 255.