3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class bar { public static function foo($data) { return $data; } } 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; } } $data = ['some','data']; post::respond_catch(function(){ return bar::foo(global $data); });
Output for 5.4.0 - 5.4.30
Parse error: syntax error, unexpected 'global' (T_GLOBAL), expecting ')' in /in/6HLDc on line 49
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected '[', expecting ')' in /in/6HLDc on line 15
Process exited with code 255.