1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- /**
- * Description of resp.php
- * 返回值基类, 统一的序列化到字符串的方法, json_encode...
- * @version
- * 1.0.0 Created at 2017-12-22. by --gwang
- * @author gwang (mail@wanggangzero.cn)
- * @copyright ? 2017-12-22, SJZ LoyalSoft Corporation & gwang. All rights reserved.
- */
- class Resp
- {
- public $err = 0;
- public $ret;
- public $msg;
- public static function ok($ret)
- {
- $resp = new Resp();
- $resp->err = 0;
- $resp->ret = $ret;
- return $resp;
- }
- public static function err($err_no, $msg)
- {
- $resp = new Resp();
- $resp->err = $err_no;
- $resp->msg = $msg;
- return $resp;
- }
- public function __toString()
- {
- return $this->toString();
- }
- public function toString()
- {
- // var_dump(\JsonUtil::encode($this));
- $str = loyalsoft\JsonUtil::encode($this);
- return $str;
- // return \gzdeflate($str);
- }
- }
|