mb_encode_mimeheader
(PHP 4 >= 4.0.6, PHP 5, PHP 7)
mb_encode_mimeheader — Encode string for MIME header
Description
$str
[, string $charset
= mb_language()
[, string $transfer_encoding
= "B"
[, string $linefeed
= "\r\n"
[, int $indent
= 0
]]]] ) : string
Encodes a given string
str
by the MIME header encoding scheme.
Parameters
-
str
-
The string being encoded. Its encoding should be same as mb_internal_encoding().
-
charset
-
charset
specifies the name of the character set in whichstr
is represented in. The default value is determined by the current NLS setting (mbstring.language). -
transfer_encoding
-
transfer_encoding
specifies the scheme of MIME encoding. It should be either "B" (Base64) or "Q" (Quoted-Printable). Falls back to "B" if not given. -
linefeed
-
linefeed
specifies the EOL (end-of-line) marker with which mb_encode_mimeheader() performs line-folding (a » RFC term, the act of breaking a line longer than a certain length into multiple lines. The length is currently hard-coded to 74 characters). Falls back to "\r\n" (CRLF) if not given. -
indent
-
Indentation of the first line (number of characters in the header before
str
).
Examples
Example #1 mb_encode_mimeheader() example
<?php
$name = ""; // kanji
$mbox = "kru";
$doma = "gtinn.mon";
$addr = mb_encode_mimeheader($name, "UTF-7", "Q") . " <" . $mbox . "@" . $doma . ">";
echo $addr;
?>
Notes
Note:
This function isn't designed to break lines at higher-level contextual break points (word boundaries, etc.). This behaviour may clutter up the original string with unexpected spaces.
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-mb-encode-mimeheader.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.