3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class post { public static function respond($status, $values = NULL) { if($values != NULL){ echo json_encode(['status' => $status, 'values' => $values]); return true; }else{ echo json_encode(['status' => $status]); return true; } return false; } public static function respond_catch($function) { try{ $values = $function(); } catch(Exception $e) { if($e->getMessage() != NULL ){ //There is a message echo json_encode(['status' => $default_message]); return false; }else{ //otherwise echo json_encode(['status' => 'Nastala chyba. Skúste to znova prosím.']); return false; } } echo json_encode(['status' => 'OK', 'values' => $values]); return true; } } class test { public static function foo() { return 'lamer'; } } post::respond_catch('test::foo')
Output for 5.4.0 - 5.4.30
Parse error: syntax error, unexpected end of file in /in/lnmQM on line 47
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected '[', expecting ')' in /in/lnmQM on line 8
Process exited with code 255.