Function name: mb_decode_mimeheader()
Applicable version: PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8
Function Description: The mb_decode_mimeheader() function decodes the MIME formatted mail header field into a UTF-8 encoded string.
Usage: string mb_decode_mimeheader ( string $str [, int $mode = 0 [, string $charset = mb_internal_encoding() ]] )
parameter:
Return value: Returns the decoded string, and returns the original string if decoding fails.
Example:
$str = '=?UTF-8?B?5bCP5piO6KaB5YWx5Y+3?='; // MIME 编码的字符串$decodedStr = mb_decode_mimeheader($str); echo $decodedStr; // 输出:你好,世界
In the example above, we have a MIME encoded string $str
that is decoded using mb_decode_mimeheader()
function. The decoded string is stored in the $decodedStr
variable and output via echo
. The output result is "Hello, World".
Note that this function automatically detects MIME encoding in the string and decodes it into a UTF-8-encoded string. If decoding fails, the function returns the original string.