<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Composes a MIME header field</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.iconv-mime-decode.html">iconv_mime_decode</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.iconv-set-encoding.html">iconv_set_encoding</a></div> <div class="up"><a href="ref.iconv.html">iconv Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.iconv-mime-encode" class="refentry"> <div class="refnamediv"> <h1 class="refname">iconv_mime_encode</h1> <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">iconv_mime_encode</span> — <span class="dc-title">Composes a <em>MIME</em> header field</span></p> </div> <div class="refsect1 description" id="refsect1-function.iconv-mime-encode-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">string</span> <span class="methodname"><strong>iconv_mime_encode</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$field_name</code></span> , <span class="methodparam"><span class="type">string</span> <code class="parameter">$field_value</code></span> [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$preferences</code><span class="initializer"> = <strong><code>NULL</code></strong></span></span> ] )</div> <p class="para rdfs-comment"> Composes and returns a string that represents a valid <em>MIME</em> header field, which looks like the following: <div class="example-contents screen"> <div class="cdata"><pre> Subject: =?ISO-8859-1?Q?Pr=FCfung_f=FCr?= Entwerfen von einer MIME kopfzeile </pre></div> </div> In the above example, "Subject" is the field name and the portion that begins with "=?ISO-8859-1?..." is the field value. </p> </div> <div class="refsect1 parameters" id="refsect1-function.iconv-mime-encode-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">field_name</code></em></span> <dd> <p class="para"> The field name. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">field_value</code></em></span> <dd> <p class="para"> The field value. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">preferences</code></em></span> <dd> <p class="para"> You can control the behaviour of <span class="function"><strong>iconv_mime_encode()</strong></span> by specifying an associative array that contains configuration items to the optional third parameter <em><code class="parameter">preferences</code></em>. The items supported by <span class="function"><strong>iconv_mime_encode()</strong></span> are listed below. Note that item names are treated case-sensitive. <table class="doctable table"> <caption><strong>Configuration items supported by <span class="function"><strong>iconv_mime_encode()</strong></span></strong></caption> <thead> <tr> <th>Item</th> <th>Type</th> <th>Description</th> <th>Default value</th> <th>Example</th> </tr> </thead> <tbody class="tbody"> <tr> <td>scheme</td> <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td> <td> Specifies the method to encode a field value by. The value of this item may be either "B" or "Q", where "B" stands for <em>base64</em> encoding scheme and "Q" stands for <em>quoted-printable</em> encoding scheme. </td> <td>B</td> <td>B</td> </tr> <tr> <td>input-charset</td> <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td> <td> Specifies the character set in which the first parameter <em><code class="parameter">field_name</code></em> and the second parameter <em><code class="parameter">field_value</code></em> are presented. If not given, <span class="function"><strong>iconv_mime_encode()</strong></span> assumes those parameters are presented to it in the <a href="iconv.configuration.html" class="link">iconv.internal_encoding</a> ini setting. </td> <td> <a href="iconv.configuration.html" class="link">iconv.internal_encoding</a> </td> <td>ISO-8859-1</td> </tr> <tr> <td>output-charset</td> <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td> <td> Specifies the character set to use to compose the <em>MIME</em> header. </td> <td> <a href="iconv.configuration.html" class="link">iconv.internal_encoding</a> </td> <td>UTF-8</td> </tr> <tr> <td>line-length</td> <td><span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span></td> <td> Specifies the maximum length of the header lines. The resulting header is "folded" to a set of multiple lines in case the resulting header field would be longer than the value of this parameter, according to <a href="http://www.faqs.org/rfcs/rfc2822" class="link external">» RFC2822 - Internet Message Format</a>. If not given, the length will be limited to 76 characters. </td> <td>76</td> <td>996</td> </tr> <tr> <td>line-break-chars</td> <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td> <td> Specifies the sequence of characters to append to each line as an end-of-line sign when "folding" is performed on a long header field. If not given, this defaults to "\r\n" (<em>CR</em> <em>LF</em>). Note that this parameter is always treated as an ASCII string regardless of the value of <em>input-charset</em>. </td> <td>\r\n</td> <td>\n</td> </tr> </tbody> </table> </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.iconv-mime-encode-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns an encoded <em>MIME</em> field on success, or <strong><code>FALSE</code></strong> if an error occurs during the encoding. </p> </div> <div class="refsect1 examples" id="refsect1-function.iconv-mime-encode-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-2478"> <p><strong>Example #1 <span class="function"><strong>iconv_mime_encode()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$preferences </span><span style="color: #007700">= array(<br /> </span><span style="color: #DD0000">"input-charset" </span><span style="color: #007700">=> </span><span style="color: #DD0000">"ISO-8859-1"</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"output-charset" </span><span style="color: #007700">=> </span><span style="color: #DD0000">"UTF-8"</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"line-length" </span><span style="color: #007700">=> </span><span style="color: #0000BB">76</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"line-break-chars" </span><span style="color: #007700">=> </span><span style="color: #DD0000">"\n"<br /></span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$preferences</span><span style="color: #007700">[</span><span style="color: #DD0000">"scheme"</span><span style="color: #007700">] = </span><span style="color: #DD0000">"Q"</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">// This yields "Subject: =?UTF-8?Q?Pr=C3=BCfung=20Pr=C3=BCfung?="<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">iconv_mime_encode</span><span style="color: #007700">(</span><span style="color: #DD0000">"Subject"</span><span style="color: #007700">, </span><span style="color: #DD0000">"Prüfung Prüfung"</span><span style="color: #007700">, </span><span style="color: #0000BB">$preferences</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$preferences</span><span style="color: #007700">[</span><span style="color: #DD0000">"scheme"</span><span style="color: #007700">] = </span><span style="color: #DD0000">"B"</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">// This yields "Subject: =?UTF-8?B?UHLDvGZ1bmcgUHLDvGZ1bmc=?="<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">iconv_mime_encode</span><span style="color: #007700">(</span><span style="color: #DD0000">"Subject"</span><span style="color: #007700">, </span><span style="color: #DD0000">"Prüfung Prüfung"</span><span style="color: #007700">, </span><span style="color: #0000BB">$preferences</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-function.iconv-mime-encode-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.imap-binary.html" class="function" rel="rdfs-seeAlso">imap_binary()</a> - Convert an 8bit string to a base64 string</span></li> <li class="member"> <span class="function"><a href="function.mb-encode-mimeheader.html" class="function" rel="rdfs-seeAlso">mb_encode_mimeheader()</a> - Encode string for MIME header</span></li> <li class="member"> <span class="function"><a href="function.imap-8bit.html" class="function" rel="rdfs-seeAlso">imap_8bit()</a> - Convert an 8bit string to a quoted-printable string</span></li> <li class="member"> <span class="function"><a href="function.quoted-printable-encode.html" class="function" rel="rdfs-seeAlso">quoted_printable_encode()</a> - Convert a 8 bit string to a quoted-printable string</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.iconv-mime-decode.html">iconv_mime_decode</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.iconv-set-encoding.html">iconv_set_encoding</a></div> <div class="up"><a href="ref.iconv.html">iconv Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>