/** * API返回 */ function api_result($result) { if (is_string($result)){ $result['flag'] = true; $result['code'] = 10000; $result['msg'] = '操作成功'; $result['data'] = $result; $result['time'] = time(); header('Content-Type:application/json; charset=utf-8'); die(json_encode($result)); } $result['flag'] = empty($result['code']) ? true: false; $result['code'] = empty($result['code']) ? 10000: $result['code']; $result['msg'] = empty($result['msg']) ? '操作成功': $result['msg']; $result['data'] = empty($result['data']) ? []: $result['data']; $result['time'] = time(); header('Content-Type:application/json; charset=utf-8'); die(json_encode($result)); }