summaryrefslogtreecommitdiff
path: root/lib/utils.php
blob: b81ddda0d13bcb43a74e834db3acc91e8d5a770b (plain)
1
2
3
4
5
6
7
8
9
10
11
<?php
function json_response(int $code, string|null $message, mixed $data)
{
    header('Content-Type: application/json');
    http_response_code($code);
    return json_encode([
        'status_code' => $code,
        'message' => $message,
        'data' => $data
    ], JSON_UNESCAPED_SLASHES);
}