mb_http_output

Set/Get HTTP output character encoding

Description

stringbool mb_http_output(stringnull $encoding = null)

Set/Get the HTTP output character encoding. Output after this function is called will be converted from the set internal encoding to encoding.

Parameters

encoding

If encoding is set, mb_http_output sets the HTTP output character encoding to encoding.

If encoding is omitted, mb_http_output returns the current HTTP output character encoding.

Return Values

If encoding is omitted, mb_http_output returns the current HTTP output character encoding. Otherwise, Returns true on success or false on failure.

Errors/Exceptions

Throws a ValueError if encoding contains null bytes.

As of PHP 8.0.0, a ValueError is thrown if encoding is an invalid encoding. Prior to PHP 8.0.0, an E_WARNING was emitted instead.

Changelog

Version Description
8.4.0 mb_http_output now throws a ValueError if encoding contains null bytes.
8.0.0 encoding is nullable now.
8.0.0 Now throws a ValueError if encoding is an invalid encoding. Previously, an E_WARNING was emitted and false was returned.

See Also

  • mb_internal_encoding
  • mb_http_input
  • mb_detect_order