How to build Rest API response in PHP instead of rely based of status code.

Member

carey

by carey , in category: PHP , a month ago

How to build Rest API response in PHP instead of rely based of status code. 😁

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
final class Response {

    public static function warning($msg) {

        exit(json_encode('Warning: ' . $msg));

    }

    public static function error($msg) {

        exit(json_encode('Error: ' . $msg));

    }

    public static function json($str, $options = 0) {

        exit(json_encode($str, $options));

    }

}


Facebook Twitter LinkedIn Telegram Whatsapp Pocket

no answers