$method(); } catch (Exception $e) { json_response($e->getCode(), $e->getMessage()); } exit(); /** * output json result * * @param int $status * @param string $status_message * @param mixed $data * * @return void */ function json_response($status, $status_message, $data = null) { header("HTTP/1.1 " . $status); $response['status'] = $status; $response['status_message'] = $status_message; $response['data'] = $data; $json_response = json_encode($response, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT); echo $json_response; exit(); }