diff options
| author | ilotterytea <iltsu@alright.party> | 2025-03-18 02:43:15 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-03-18 02:43:15 +0500 |
| commit | eacbea32efb110363e461c344100ca9511a97630 (patch) | |
| tree | e74d86289698ebb376a199251803f61a9cab70d2 /lib | |
| parent | ad1f0a370d432701bc5fe4eb6fa1fb23f94c1293 (diff) | |
upd: json responses
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/utils.php | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/utils.php b/lib/utils.php new file mode 100644 index 0000000..b5f8431 --- /dev/null +++ b/lib/utils.php @@ -0,0 +1,11 @@ +<?php +function json_response(mixed $data, string|null $message, int $code = 200) +{ + http_response_code($code); + header('Content-Type: application/json'); + echo json_encode([ + 'status_code' => $code, + 'message' => $message, + 'data' => $data + ]); +}
\ No newline at end of file |
