response.php
资源名称:ext-3.1.0.zip [点击查看]
上传用户:dawnssy
上传日期:2022-08-06
资源大小:9345k
文件大小:1k
源码类别:
JavaScript
开发平台:
JavaScript
- <?php
- /**
- * @class Response
- * A simple JSON Response class.
- */
- class Response {
- public $success, $data, $message, $errors, $tid, $trace;
- public function __construct($params = array()) {
- $this->success = isset($params["success"]) ? $params["success"] : false;
- $this->message = isset($params["message"]) ? $params["message"] : '';
- $this->data = isset($params["data"]) ? $params["data"] : array();
- }
- public function to_json() {
- return json_encode(array(
- 'success' => $this->success,
- 'message' => $this->message,
- 'data' => $this->data
- ));
- }
- }