接口返回值 Json格式数据

/**
	 * 接口返回值
	 * Json格式数据
	 */
	public function returns($status,$code,$msg = '',$data = NULL,$callback = NULL){

        // 将时间递归转换为北京标准时间



        if(empty($msg)){
            // $msg = $this->lang->line(''.$code);
            //var_dump($msg);echo "
"; } if(empty($callback)){ if($data === NULL){ if (empty($this->callback)) { echo json_encode(array('Status' => $status,'ErrorCode' => $code,'Msg' => $msg)); } else{ echo $this->callback.'('.json_encode(array('Status' => $status,'ErrorCode' => $code,'Msg' => $msg)) . ')'; } }else{ if (empty($this->callback)) { echo json_encode(array('Status' => $status,'ErrorCode' => $code,'Msg' => $msg,'Data' =>$data)); } else{ echo $this->callback.'('.json_encode(array('Status' => $status,'ErrorCode' => $code,'Msg' => $msg,'Data' =>$data)).')'; } } }else{ if($data === NULL){ echo $callback.'('.json_encode(array('Status' => $status,'ErrorCode' => $code,'Msg' => $msg)).')'; }else{ echo $callback.'('.json_encode(array('Status' => $status,'ErrorCode' => $code,'Msg' => $msg,'Data' =>$data)).')'; } } exit(); }

你可能感兴趣的:(方法,function)