PHP – Get or set the HTTP output character encoding with mb_http_output()

PHPServer Side ProgrammingProgramming

The mb_http_output() function in PHP is used to get or set the HTTP output character encoding. An output, after this function is called, will be converted from the set internal encoding to the specified encoding.

Syntax

string|bool mb_http_output(str $encoding = null)

Parameters

mb_http_output() accepts only a single parameter −

  • $encoding − It is used to set the HTTP output character encoding to the encoding. If the encoding is omitted, then mb_http_output() will return the current HTTP output character encoding.

Return Values

If the encoding is omitted, then the mb_http_output() function will return the current HTTP output character encoding. Otherwise, it returns True on success and False on failure.

Example

<?php
   // It will return the output character encoding
   $string = mb_http_output();
   var_dump($string);
?>

Output

It will produce the following output −

string(5) "UTF-8"
raja
Published on 11-Oct-2021 13:11:03
Advertisements