200, 'message' => 'Access granted', ]; } else { $result_array = [ 'code' => 403, 'message' => 'Access forbidden', ]; } } else { $result_array = [ 'code' => 401, 'message' => 'Unauthorized', ]; } } else { // OPTIONS request automatically works if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') { $result_array = [ 'code' => 200, 'message' => 'Options request accepted', ]; } else { $result_array = [ 'code' => 401, 'message' => 'Unauthorized', ]; } } // Numeric data in array must be numeric data in json (not text) $result = json_encode($result_array, JSON_NUMERIC_CHECK); echo $result;