PHP--通用化API接口数据输出 封装
1 /** 2 * 通用化API接口数据输出 3 * author qinpeizhou 4 * @param $message 5 * @param array $data 6 * @param int $httpCode 7 * @return \think\response\Json 8 */ 9 function show($message,$data=[],$httpCode=200){ 10 $data = [ 11 'code' => $httpCode, 12 'message' => $message, 13 'data' => (object)$data 14 ]; 15 echo json_encode($data,$httpCode); 16 }