<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.iconv.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.iconv-mime-encode.php',
    1 => 'iconv_mime_encode',
    2 => 'Composes a MIME header field',
  ),
  'up' => 
  array (
    0 => 'ref.iconv.php',
    1 => 'iconv Functions',
  ),
  'prev' => 
  array (
    0 => 'function.iconv-mime-decode-headers.php',
    1 => 'iconv_mime_decode_headers',
  ),
  'next' => 
  array (
    0 => 'function.iconv-set-encoding.php',
    1 => 'iconv_set_encoding',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/iconv/functions/iconv-mime-encode.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.iconv-mime-encode" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">iconv_mime_encode</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">iconv_mime_encode</span> &mdash; <span class="dc-title">Composes a <code class="literal">MIME</code> 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="methodname"><strong>iconv_mime_encode</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$field_name</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$field_value</code></span>, <span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$options</code><span class="initializer"> = []</span></span>): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   Composes and returns a string that represents a valid <code class="literal">MIME</code>
   header field, which looks like the following:
   <div class="example-contents screen">
<div class="descriptioncode"><pre class="descriptioncode">Subject: =?ISO-8859-1?Q?Pr=FCfung_f=FCr?= Entwerfen von einer MIME kopfzeile</pre>
</div>
   </div>
   In the above example, &quot;Subject&quot; is the field name and the portion that
   begins with &quot;=?ISO-8859-1?...&quot; 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><code class="parameter">field_name</code></dt>
     <dd>
      <p class="para">
       The field name.
      </p>
     </dd>
    
    
     <dt><code class="parameter">field_value</code></dt>
     <dd>
      <p class="para">
       The field value.
      </p>
     </dd>
    
    
     <dt><code class="parameter">options</code></dt>
     <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 <code class="parameter">options</code>.
       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.php" 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 &quot;B&quot; or &quot;Q&quot;, where &quot;B&quot; stands for
            <code class="literal">base64</code> encoding scheme and &quot;Q&quot; stands for
            <code class="literal">quoted-printable</code> encoding scheme.
           </td>
           <td>B</td>
           <td>B</td>
          </tr>

          <tr>
           <td>input-charset</td>
           <td><span class="type"><a href="language.types.string.php" class="type string">string</a></span></td>
           <td>
            Specifies the character set in which the first parameter
            <code class="parameter">field_name</code> and the second parameter
            <code class="parameter">field_value</code> 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.php" class="link">iconv.internal_encoding</a>
            ini setting.
           </td>
           <td>
            <a href="iconv.configuration.php" 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.php" class="type string">string</a></span></td>
           <td>
            Specifies the character set to use to compose the
            <code class="literal">MIME</code> header.
           </td>
           <td>
            <a href="iconv.configuration.php" 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.php" class="type int">int</a></span></td>
           <td>
            Specifies the maximum length of the header lines. The resulting
            header is &quot;folded&quot; 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="https://datatracker.ietf.org/doc/html/rfc2822" class="link external">&raquo;&nbsp;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.php" 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 &quot;folding&quot; is performed on a long header
            field. If not given, this defaults to &quot;\r\n&quot;
            (<code class="literal">CR</code> <code class="literal">LF</code>). Note that
            this parameter is always treated as an ASCII string regardless
            of the value of <code class="literal">input-charset</code>.
           </td>
           <td>\r\n</td>
           <td>\n</td>
          </tr>

         </tbody>
        
       </table>

      </p>
     </dd>
    
   </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 <code class="literal">MIME</code> field on success,
   or <strong><code><a href="reserved.constants.php#constant.false">false</a></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-1">
    <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">&lt;?php<br />$preferences </span><span style="color: #007700">= array(<br />    </span><span style="color: #DD0000">"input-charset" </span><span style="color: #007700">=&gt; </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">=&gt; </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">=&gt; </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">=&gt; </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">?&gt;</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><span class="function"><a href="function.imap-binary.php" class="function" rel="rdfs-seeAlso">imap_binary()</a> - Convert an 8bit string to a base64 string</span></li>
    <li><span class="function"><a href="function.mb-encode-mimeheader.php" class="function" rel="rdfs-seeAlso">mb_encode_mimeheader()</a> - Encode string for MIME header</span></li>
    <li><span class="function"><a href="function.imap-8bit.php" class="function" rel="rdfs-seeAlso">imap_8bit()</a> - Convert an 8bit string to a quoted-printable string</span></li>
    <li><span class="function"><a href="function.quoted-printable-encode.php" 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><?php manual_footer($setup); ?>