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() { foreach($this->input as $key=>$value) { if($key == 2) throw new Exception('hello exception'); } } } function retry(Dummy $dum) { try { $dum->run(); } catch(Exception $e) { // solve the exception if($this->input[2]) unset($this->input[2]); retry($dum); } } $dum = new Dummy; retry($dum);
Output for 7.0.0 - 7.3.0rc4
Fatal error: Uncaught Error: Using $this when not in object context in /in/J9CEs:25 Stack trace: #0 /in/J9CEs(33): retry(Object(Dummy)) #1 {main} thrown in /in/J9CEs on line 25
Process exited with code 255.
Output for 5.0.0 - 5.6.28
Fatal error: Using $this when not in object context in /in/J9CEs on line 25
Process exited with code 255.
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/J9CEs 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/J9CEs 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/J9CEs on line 4
Process exited with code 255.