Last active
June 25, 2017 04:28
-
-
Save mouyong/551c252cfa766d3c0c822b2950be43e1 to your computer and use it in GitHub Desktop.
转换 Ajax 响应的 json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function json($status, $data = null, $message = 'success') | |
| { | |
| if (is_null($data)) { | |
| $data = ['status' => $status, 'message' => $message]; | |
| } elseif (is_string($data)) { | |
| $data = ['status' => $status, 'message' => $data]; | |
| } else { | |
| $data = ['status' => $status, 'message' => $message, 'data' => $data]; | |
| } | |
| return json_encode($data); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment