3v4l.org

run code in 200+ PHP versions simultaneously
<?php function exception_error_handler($severity, $message, $file, $line) { if (!(error_reporting() & $severity)) { // This error code is not included in error_reporting return; } throw new ErrorException($message, 0, $severity, $file, $line); } set_error_handler("exception_error_handler"); $o=new StdClass(); $o->f=function(){ echo "i ran!"; }; try{ $o->f(); }catch(Throwable $ex){ echo 'didn\'t work: $o->f()',PHP_EOL; } try{ call_user_func([$o,'f']); }catch(Throwable $ex){ echo 'didn\'t work: call_user_func([$o,\'f\'])',PHP_EOL; } try{ get_object_vars($o)['f'](); }catch(Throwable $ex){var_dump($ex); echo 'didn\'t work: get_object_vars($o)[\'f\']()',PHP_EOL; }
Output for 7.0.0 - 7.4.2
didn't work: $o->f() didn't work: call_user_func([$o,'f']) i ran!
Output for 5.4.0 - 5.6.40
Parse error: syntax error, unexpected '(' in /in/MppBE on line 26
Process exited with code 255.
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[', expecting ')' in /in/MppBE on line 21
Process exited with code 255.
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/MppBE on line 12
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in /in/MppBE on line 12
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_NEW in /in/MppBE on line 7
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_NEW in /in/MppBE on line 7
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/MppBE on line 7
Process exited with code 255.