| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- class JSON {
- public static function header() {
- header("Content-Type: application/json");
- }
- public static function success($array=array()) {
- $flags = PRODUCTION ? 0 : JSON_PRETTY_PRINT;
- $output = array(
- "success" => true,
- );
- $output = array_merge($output, $array);
- die(json_encode($output, $flags));
- }
- public static function fail($array = []) {
- $flags = PRODUCTION ? 0 : JSON_PRETTY_PRINT;
- $output = array(
- "success" => false
- );
- if(is_string($array)) {
- $array = [
- "message" => $array,
- ];
- }
- $output = array_merge($output, $array);
- die(json_encode($output, $flags));
- }
- }
|