In PHP, the iconv_mime_encode() function is used to compose MIME header fields. This is a built-in PHP function.
string iconv_mime_encode(string $field_name, string $field_value, array $options=[])
iconv_mime_encode() The function is used to combine and return a string representing a valid MIME header field as shown below-
Subject: =ISO-8859-1?Q?Pr=FCfung_f=FFCr?= Entwerfen von einer MIME kopfzeile
Note -In the above example, Subject - is the field name, ending with "=ISO-8859-1?..."# The part starting with ## is the field value.
Parametersiconv_mime_encode()Accepts three different parameters− $field_name, $field_value, and $options.
$field_name - This parameter is used for the field name.
#$field_value - This parameter is used for the field value.
$options - Using this parameter, you can control the behavior of iconv_mime_encode() by specifying an associative array that contains configuration of optional parameters item.
iconv_mime_encode()
This scheme specifies the method for encoding field values. The item value can be B (base64) or Q (quoted-printable) encoding scheme.
| # #Input character set | String | ||
Specifies the character set, field_name is the first parameters, field_value is the second parameter. If these arguments are not given, the iconv_mime_encode() function assumes that it may be present in the iconv.internal_charset ini setting. | iconv.internal_charset | ##ISO-8859-1 | Output character set | String |
It specifies the character set used to make up the MIME header. If not given, it will use the input character set value. | input_charset is used as the default value | ##UTF-8
| Line length | ##Integer |
76 | ##996 |
| Line break | String |
" (CR LF) | ##\r##Example 1 - Use "Q" quotes to print the encoding scheme Live Demo <?php // used configuration items supported by iconv_mime_encode() $options = array( "input-charset" => "ISO-8859-2", "output-charset" => "UTF-8", "line-length" => 76, "line-break-chars" => "" ); // Q quoted-printable encoding scheme is used $options["scheme"] = "Q"; // Below code will show the result as // "Subject: =?UTF-8?Q?Pr=C3=BCfung=20Pr=C3=BCfung?=" echo iconv_mime_encode("Subject", "Prüfung Prüfung", $options); ?> Copy after login | Output Subject: =?UTF-8?Q?Pr=C3=83=C2=BCfung=20Pr=C3=83=C2=BCfung?= Copy after login <?php // used configuration items supported by iconv_mime_encode() $options = array( "input-charset" => "ISO-8859-1", "output-charset" => "UTF-8", "line-length" => 76, "line-break-chars" => "" ); // B base64 encoding scheme is used $options["scheme"] = "B"; // Below code will show the result as //"Subject: =?UTF-8?B?UHJlw4PCp29zIE9sw4PCoC50eHQ=?=" echo iconv_mime_encode("Subject", "Preços Olà.txt", $options); ?> Copy after login Subject: =?UTF-8?B?UHJlw4PCp29zIE9sw4PCoC50eHQ=?= Copy after login The above is the detailed content of Use the iconv_mime_encode() function to build a PHP code for a MIME header field. For more information, please follow other related articles on the PHP Chinese website!
Related labels:
source:tutorialspoint.com
Previous article:Demonstrate dependency injection in PHP using Symfony components
Next article:How can we create a MySQL table using PHP script?
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Latest Issues
Related Topics
More>
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
|