summaryrefslogtreecommitdiff
path: root/lib/utils.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/utils.php')
-rw-r--r--lib/utils.php11
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