PHP mb_http_output() Function Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report The mb_http_output() function is an inbuilt function in PHP that is used to set and retrieve the character encoding. This function allows you to specify a character encoding for HTTP response. Syntax: mb_http_output($encoding )Parameters: This function accepts only one parameter which is described below. $encoding: This is the optional parameter that specifies the character encoding.Return Value: This function returns the boolean value if the function successfully executes, it will return "true" otherwise it will return false. If the $encoding removes the function, it will be used by default encoding. Program 1: The following program demonstrates the mb_http_output() function. PHP <?php // Get the current HTTP output character encoding $encoding = mb_http_output(); echo "Current HTTP output encoding: " . $encoding; ?> OutputCurrent HTTP output encoding: UTF-8Program 2: The following program demonstrates the mb_http_output() function. PHP <?php $encoding = "UTF-8"; $condition = true; function custom_mb_http_output($encoding, $condition) { // Validate the encoding parameter if (!in_array($encoding, mb_list_encodings())) { return false; // Invalid encoding } // Conditionally set the character encoding // based on a condition if ($condition) { mb_http_output($encoding); return true; // Encoding set successfully } else { return false; // Encoding not set } } if (custom_mb_http_output($encoding, $condition)) { echo "Character encoding set to $encoding for HTTP output."; } else { echo "Failed to set character encoding for HTTP output."; } ?> Output: Character encoding set to UTF-8 for HTTP output. Reference: https://www.php.net/manual/en/function.mb-http-output.php Comment More infoAdvertise with us Next Article PHP mb_http_output() Function N neeraj3304 Follow Improve Article Tags : PHP PHP-function PHP-Multibyte-String Similar Reads PHP mb_http_input() Function The mb_http_input() is an inbuilt function in PHP that facilitates the HTTP input character encoding to be detected. Syntax: mb_http_input(?string $type = null): array|string|falseParameter: type: This parameter takes values like "G" for GET, "P" for POST, "C" for COOKIE, "S" for string, "L" for the 1 min read PHP | hrtime() Function The hrtime() function is an inbuilt function in PHP which returns the high-resolution time of the system. Syntax: mixed hrtime( bool $is_num_return ); Parameter: This function accepts a single parameter as mentioned above and described below: $is_num_return: It is optional parameter of Boolean type. 1 min read PHP | inet_ntop() Function The inet_ntop() function is an inbuilt function in PHP which converts a 32bit IPv4 or 128bit IPv6 address into a readable format. Syntax: string inet_ntop( string $ip_address ) Parameter: This function accepts one parameter as mentioned above and described below: $ip_address: It is required paramete 1 min read PHP ob_get_level() Function The ob_get_level() function is an inbuilt function in PHP that is used to get the current output buffer level in a nested level. Output buffering is a feature in PHP that allows you to capture and manipulate output before it is sent to the browser or client. Syntaxob_get_level(): intParameter This f 2 min read PHP | getservbyport() Function The getservbyport() function is an inbuilt function in PHP which returns the Internet service for given protocol and port number. Syntax: string getservbyport( int $port, string $protocol) Parameters: This function accepts two parameters as mentioned above and described below: $protocol: It is requi 1 min read Like