response.php
资源名称:ext-3.0.0.zip [点击查看]
上传用户:shuoshiled
上传日期:2018-01-28
资源大小:10124k
文件大小:1k
源码类别:
中间件编程
开发平台:
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
- ));
- }
- }