public function setContentType($contentType, $charset = null) {
		// process shorthands for the content type or MIME type information
		switch ($contentType) {
			case 'text':
				$contentType = 'text/plain';
				$charset = isset($charset) ? $charset : 'auto';
				break;
			case 'html':
				$contentType = 'text/html';
				$charset = isset($charset) ? $charset : 'auto';
				break;
			case 'json':
				$contentType = 'application/json';
				break;
			case 'xml':
				$contentType = 'text/xml';
				$charset = isset($charset) ? $charset : 'auto';
				break;
		}

		// if the character encoding is to be determined automatically
		if ($charset === 'auto') {
			// if the internal character encoding has been configured
			if (isset($_ENV['APP_CHARSET'])) {
				// use the encoding from the configuration
				$charset = strtolower($_ENV['APP_CHARSET']);
			}
			// if there is no encoding in the configuration
			else {
				// use UTF-8 as the default
				$charset = 'utf-8';
			}
		}

		$headerLine = 'Content-Type: ' . $contentType;

		if ($charset !== null) {
			$headerLine .= '; charset=' . $charset;
		}

		\header($headerLine);
	}
public function setContentType($contentType, $charset = null) {
		// process shorthands for the content type or MIME type information
		switch ($contentType) {
			case 'text':
				$contentType = 'text/plain';
				$charset = isset($charset) ? $charset : 'auto';
				break;
			case 'html':
				$contentType = 'text/html';
				$charset = isset($charset) ? $charset : 'auto';
				break;
			case 'json':
				$contentType = 'application/json';
				break;
			case 'xml':
				$contentType = 'text/xml';
				$charset = isset($charset) ? $charset : 'auto';
				break;
		}

		// if the character encoding is to be determined automatically
		if ($charset === 'auto') {
			// if the internal character encoding has been configured
			if (isset($_ENV['APP_CHARSET'])) {
				// use the encoding from the configuration
				$charset = strtolower($_ENV['APP_CHARSET']);
			}
			// if there is no encoding in the configuration
			else {
				// use UTF-8 as the default
				$charset = 'utf-8';
			}
		}

		$headerLine = 'Content-Type: ' . $contentType;

		if ($charset !== null) {
			$headerLine .= '; charset=' . $charset;
		}

		\header($headerLine);
	}
public function setContentType ( $ contentType , $ charset = null ) { // process shorthands for the content type or MIME type information switch ( $ contentType ) { case 'text' : $ contentType = 'text/plain' ; $ charset = isset ( $ charset ) ? $ charset : 'auto' ; break ; case 'html' : $ contentType = 'text/html' ; $ charset = isset ( $ charset ) ? $ charset : 'auto' ; break ; case 'json' : $ contentType = 'application/json' ; break ; case 'xml' : $ contentType = 'text/xml' ; $ charset = isset ( $ charset ) ? $ charset : 'auto' ; break ; } // if the character encoding is to be determined automatically if ( $ charset === 'auto' ) { // if the internal character encoding has been configured if ( isset ( $ _ENV [ 'APP_CHARSET' ] ) ) { // use the encoding from the configuration $ charset = strtolower ( $ _ENV [ 'APP_CHARSET' ] ) ; } // if there is no encoding in the configuration else { // use UTF-8 as the default $ charset = 'utf-8' ; } } $ headerLine = 'Content-Type: ' . $ contentType ; if ( $ charset !== null ) { $ headerLine .= '; charset=' . $ charset ; } \ header ( $ headerLine ) ; }
Sets the content type and character encoding for the HTTP response

@param string $contentType the content type or MIME type (or `text`, `html`, `json` or `xml` as shorthands)
@param string|null $charset (optional) the character encoding (or `auto` for the default)
Sets the content type and character encoding for the HTTP response