Function name: mb_encode_mimeheader()
Function function: Encode the string into a printable ASCII string in the MIME header.
Applicable version: PHP 4 >= 4.0.6, PHP 5, PHP 7
Syntax: string mb_encode_mimeheader ( string $str [, string $charset = mb_internal_encoding() [, string $transfer_encoding = "B" [, string $linefeed = "\r\n" [, int $indent = 0 ]]]] )
Parameter description:
Return value: Returns the encoded string.
Example:
$text = "Hello, 世界!"; $encodedText = mb_encode_mimeheader($text, "UTF-8", "B", "\r\n", 4); echo $encodedText;
Output result:
=?UTF-8?B?SGVsbG8sIOWPrOWtlw==?=
Explanation: The mb_encode_mimeheader() function encodes the string "Hello, World!" into a printable ASCII string in the MIME header. The UTF-8 character set is used for encoding, Base64 transmission encoding method is used, the line ends are "\r\n", and the indented characters are 4. The final output encoding result is "=?UTF-8?B?SGVsbG8sIOWPrOWtlw==?=".