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 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 PHP | print_r() Function The print_r() function is a built-in function in PHP and is used to print or display information stored in a variable. Syntax: print_r( $variable, $isStore ) Parameters: This function accepts two parameters as shown in above syntax and described below. $variable: This parameter specifies the variabl 2 min read PHP ob_get_length() Function The ob_get_length() function is an inbuilt function in PHP that is used to get the length of the current output buffer. The output buffer length is the number of bytes in the buffer. Syntax: ob_get_length(): int|falseParameters: This function does not accept any parameter. Return Values: The ob_get_ 2 min read PHP | getprotobynumber() Function The getprotobynumber() function is an inbuilt function in PHP which returns the protocol name for a specified protocol number. Syntax: string getprotobynumber( int $protocol_number ) Parameters: This function accepts single parameter $protocol_number which is required. It specifies the protocol numb 1 min read PHP | ip2long() Function The ip2long() function is an inbuilt function in PHP that converts IPv4 address (dotted IP address) into a long integer. Syntax:Â int ip2long( string $ip_address ) Parameters: This function accepts single parameter as mentioned above and described below:Â Â $ip_address: It is required parameter which 2 min read PHP | opendir() Function The opendir() function in PHP is an inbuilt function which is used to open a directory handle. The path of the directory to be opened is sent as a parameter to the opendir() function and it returns a directory handle resource on success, or FALSE on failure. The opendir() function is used to open up 2 min read Like