src/Header.php
final public static function print_json(
		int $errno=0, $data=null, int $http_code=200, int $cache=0
	) {
		$json = json_encode(compact('errno', 'data'));
		self::start_header($http_code, $cache, [
			'Content-Length: ' . strlen($json),
			'Content-Type: application/json',
		]);
		static::halt($json);
	}
final public static function print_json(
		int $errno=0, $data=null, int $http_code=200, int $cache=0
	) {
		$json = json_encode(compact('errno', 'data'));
		self::start_header($http_code, $cache, [
			'Content-Length: ' . strlen($json),
			'Content-Type: application/json',
		]);
		static::halt($json);
	}
final public static function print_json ( int $ errno = 0 , $ data = null , int $ http_code = 200 , int $ cache = 0 ) { $ json = json_encode ( compact ( 'errno' , 'data' ) ) ; self :: start_header ( $ http_code , $ cache , [ 'Content-Length: ' . strlen ( $ json ) , 'Content-Type: application/json' , ] ) ; static :: halt ( $ json ) ; }
Convenience method for JSON response.

@param int $errno Error number to return.
@param array $data Data to return.
@param int $http_code Valid HTTP response code.
@param int $cache Cache duration in seconds. 0 for no cache.
Convenience method for JSON response .