mb_http_output()
mb_http_output() — Set/Get HTTP output character encoding.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
Set/Get the HTTP output character encoding. Output after this function is called will be converted from the set internal encoding to encoding.
Signature
mb_http_output(?string $encoding = null): string|bool
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $encoding | ?string | If encoding is set, mb_http_output() sets the HTTP output character encoding to encoding. |
Return value
If encoding is omitted, mb_http_output() returns the current HTTP output character encoding. Otherwise, Returns true on success or false on failure.
Example
The PHP manual ships no example for mb_http_output(); the signature and the parameter table above are the contract.
Changelog
| Version | Change |
|---|---|
| 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()
All PHP 8.5 built-in functions
Reference card built from the PHP manual page mb_http_output() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.