downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/function.iconv-mime-encode.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = 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',
  ),
 
'up' =>
  array (
   
0 => 'ref.iconv.php',
   
1 => 'iconv Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.iconv-mime-decode.php',
   
1 => 'iconv_mime_decode',
  ),
 
'next' =>
  array (
   
0 => 'function.iconv-set-encoding.php',
   
1 => 'iconv_set_encoding',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<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> &mdash; <span class="dc-title">Composes a <i>MIME</i> header field</span></p>

 </div>
 
 <a name="function.iconv-mime-encode.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><b>iconv_mime_encode</b></span>
    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$field_name</tt></span>
   , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$field_value</tt></span>
   [, <span class="methodparam"><span class="type">array</span> <tt class="parameter">$preferences</tt><span class="initializer"> = NULL</span></span>
  ] )</div>

  <p class="para rdfs-comment">
   Composes and returns a string that represents a valid <i>MIME</i>
   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, &quot;Subject&quot; is the field name and the portion that
   begins with &quot;=?ISO-8859-1?...&quot; is the field value.
  </p>
 </div>


 <a name="function.iconv-mime-encode.parameters"></a><div class="refsect1 parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   </p><dl>

    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">field_name</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       The field name.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">field_value</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       The field value.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">preferences</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       You can control the behaviour of <b>iconv_mime_encode()</b>
       by specifying an associative array that contains configuration items
       to the optional third parameter <i><tt class="parameter">preferences</tt></i>
.
       The items supported by <b>iconv_mime_encode()</b> are
       listed below. Note that item names are treated case-sensitive.
       </p><table class="doctable table">
        <caption><b>Configuration items supported by <b>iconv_mime_encode()</b></b></caption>
       
         <thead valign="middle">
          <tr valign="middle">
           <th>Item</th>
           <th>Type</th>
           <th>Description</th>
           <th>Default value</th>
           <th>Example</th>
          </tr>

         </thead>

         <tbody valign="middle" class="tbody">
          <tr valign="middle">
           <td align="left">scheme</td>
           <td align="left"><a href="language.types.string.php" class="type string">string</a></td>
           <td align="left">
            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
            <i>base64</i> encoding scheme and &quot;Q&quot; stands for
            <i>quoted-printable</i> encoding scheme.
           </td>
           <td align="left">B</td>
           <td align="left">B</td>
          </tr>

          <tr valign="middle">
           <td align="left">input-charset</td>
           <td align="left"><a href="language.types.string.php" class="type string">string</a></td>
           <td align="left">
            Specifies the character set in which the first parameter
            <i><tt class="parameter">field_name</tt></i>
 and the second parameter
            <i><tt class="parameter">field_value</tt></i>
 are presented. If not given,
            <b>iconv_mime_encode()</b> assumes those parameters
            are presented to it in the
            <a href="iconv.configuration.php" class="link">iconv.internal_encoding</a>
            ini setting.
           </td>
           <td align="left">
            <a href="iconv.configuration.php" class="link">iconv.internal_encoding</a>
           </td>
           <td align="left">ISO-8859-1</td>
          </tr>

          <tr valign="middle">
           <td align="left">output-charset</td>
           <td align="left"><a href="language.types.string.php" class="type string">string</a></td>
           <td align="left">
            Specifies the character set to use to compose the
            <i>MIME</i> header. If not given, the same value as
            <i>input-charset</i> will be used.
           </td>
           <td align="left">
            <a href="iconv.configuration.php" class="link">iconv.internal_encoding</a>
           </td>
           <td align="left">UTF-8</td>
          </tr>

          <tr valign="middle">
           <td align="left">line-length</td>
           <td align="left"><a href="language.types.integer.php" class="type integer">integer</a></td>
           <td align="left">
            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="http://www.faqs.org/rfcs/rfc2822" class="link external">&raquo; RFC2822 - Internet Message Format</a>.
            If not given, the length will be limited to 76 characters.
           </td>
           <td align="left">76</td>
           <td align="left">996</td>
          </tr>

          <tr valign="middle">
           <td align="left">line-break-chars</td>
           <td align="left"><a href="language.types.string.php" class="type string">string</a></td>
           <td align="left">
            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;
            (<i>CR</i> <i>LF</i>). Note that
            this parameter is always treated as an ASCII string regardless
            of the value of <i>input-charset</i>.
           </td>
           <td align="left">\r\n</td>
           <td align="left">\n</td>
          </tr>

         </tbody>
       
       </table>
<p>
      </p>
     </dd>

   
   </dl>
<p>
  </p>
 </div>


 <a name="function.iconv-mime-encode.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns an encoded <i>MIME</i> field on success,
   or <b><tt class="constant">FALSE</tt></b> if an error occurs during the encoding.
  </p>
 </div>


 <a name="function.iconv-mime-encode.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   </p><div class="example">
    <p><b>Example #1 <b>iconv_mime_encode()</b> example</b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$preferences&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"input-charset"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"ISO-8859-1"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"output-charset"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"UTF-8"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"line-length"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">76</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"line-break-chars"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</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">]&nbsp;=&nbsp;</span><span style="color: #DD0000">"Q"</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">//&nbsp;This&nbsp;yields&nbsp;"Subject:&nbsp;=?UTF-8?Q?Pr=C3=BCfung_Pr=C3=BCfung?="<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">iconv_mime_encode</span><span style="color: #007700">(</span><span style="color: #DD0000">"Subject"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Prüfung&nbsp;Prüfung"</span><span style="color: #007700">,&nbsp;</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">]&nbsp;=&nbsp;</span><span style="color: #DD0000">"B"</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">//&nbsp;This&nbsp;yields&nbsp;"Subject:&nbsp;=?UTF-8?B?UHLDvGZ1bmcgUHLDvGZ1bmc=?="<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">iconv_mime_encode</span><span style="color: #007700">(</span><span style="color: #DD0000">"Subject"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Prüfung&nbsp;Prüfung"</span><span style="color: #007700">,&nbsp;</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>
  </p>
 </div>


 <a name="function.iconv-mime-encode.seealso"></a><div class="refsect1 seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   </p><ul class="simplelist">
    <li class="member"><a href="function.imap-binary.php" class="function" rel="rdfs-seeAlso">imap_binary()</a> - Convert an 8bit string to a base64 string</li>
    <li class="member"><a href="function.mb-encode-mimeheader.php" class="function" rel="rdfs-seeAlso">mb_encode_mimeheader()</a> - Encode string for MIME header</li>
    <li class="member"><a href="function.imap-8bit.php" class="function" rel="rdfs-seeAlso">imap_8bit()</a> - Convert an 8bit string to a quoted-printable string</li>
    <li class="member"><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</li>
   </ul><p>
  </p>
 </div>


</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites