Source of: /manual/en/function.iconv-mime-decode-headers.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-decode-headers.php',
1 => 'iconv_mime_decode_headers',
),
'up' =>
array (
0 => 'ref.iconv.php',
1 => 'iconv Functions',
),
'prev' =>
array (
0 => 'function.iconv-get-encoding.php',
1 => 'iconv_get_encoding',
),
'next' =>
array (
0 => 'function.iconv-mime-decode.php',
1 => 'iconv_mime_decode',
),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);
manual_header();
?>
<div id="function.iconv-mime-decode-headers" class="refentry">
<div class="refnamediv">
<h1 class="refname">iconv_mime_decode_headers</h1>
<p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">iconv_mime_decode_headers</span> — <span class="dc-title">Decodes multiple <i>MIME</i> header fields at once</span></p>
</div>
<a name="function.iconv-mime-decode-headers.description"></a><div class="refsect1 description">
<h3 class="title">Description</h3>
<div class="methodsynopsis dc-description">
<span class="type">array</span> <span class="methodname"><b>iconv_mime_decode_headers</b></span>
( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$encoded_headers</tt></span>
[, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$mode</tt><span class="initializer"> = 0</span></span>
[, <span class="methodparam"><span class="type">string</span> <tt class="parameter">$charset</tt><span class="initializer"> = ini_set("iconv.internal_encoding")</span></span>
]] )</div>
<p class="para rdfs-comment">
Decodes multiple <i>MIME</i> header fields at once.
</p>
</div>
<a name="function.iconv-mime-decode-headers.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">encoded_headers</tt></i>
</span>
</dt><dd class="listitem">
<p class="para">
The encoded headers, as a string.
</p>
</dd>
<dt class="varlistentry">
<span class="term"><i><tt class="parameter">mode</tt></i>
</span>
</dt><dd class="listitem">
<p class="para">
<i><tt class="parameter">mode</tt></i>
determines the behaviour in the event
<b>iconv_mime_decode_headers()</b> encounters a malformed
<i>MIME</i> header field. You can specify any combination
of the following bitmasks.
</p><table class="doctable table">
<caption><b>Bitmasks acceptable to <b>iconv_mime_decode_headers()</b></b></caption>
<thead valign="middle">
<tr valign="middle">
<th>Value</th>
<th>Constant</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="middle" class="tbody">
<tr valign="middle">
<td align="left">1</td>
<td align="left">ICONV_MIME_DECODE_STRICT</td>
<td align="left">
If set, the given header is decoded in full conformance with the
standards defined in <a href="http://www.faqs.org/rfcs/rfc2047" class="link external">» RFC2047</a>.
This option is disabled by default because there are a lot of
broken mail user agents that don't follow the specification and don't
produce correct <i>MIME</i> headers.
</td>
</tr>
<tr valign="middle">
<td align="left">2</td>
<td align="left">ICONV_MIME_DECODE_CONTINUE_ON_ERROR</td>
<td align="left">
If set, <b>iconv_mime_decode_headers()</b>
attempts to ignore any grammatical errors and continue to process
a given header.
</td>
</tr>
</tbody>
</table>
<p>
</p>
</dd>
<dt class="varlistentry">
<span class="term"><i><tt class="parameter">charset</tt></i>
</span>
</dt><dd class="listitem">
<p class="para">
The optional <i><tt class="parameter">charset</tt></i>
parameter specifies the
character set to represent the result by. If omitted,
<a href="iconv.configuration.php" class="link">iconv.internal_encoding</a>
will be used.
</p>
</dd>
</dl>
<p>
</p>
</div>
<a name="function.iconv-mime-decode-headers.returnvalues"></a><div class="refsect1 returnvalues">
<h3 class="title">Return Values</h3>
<p class="para">
Returns an associative array that holds a whole set of
<i>MIME</i> header fields specified by
<i><tt class="parameter">encoded_headers</tt></i>
on success, or <b><tt class="constant">FALSE</tt></b>
if an error occurs during the decoding.
</p>
<p class="para">
Each key of the return value represents an individual
field name and the corresponding element represents a field value.
If more than one field of the same name are present,
<b>iconv_mime_decode_headers()</b> automatically incorporates
them into a numerically indexed array in the order of occurrence.
</p>
</div>
<a name="function.iconv-mime-decode-headers.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_decode_headers()</b> example</b></p>
<div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB"><?php<br />$headers_string </span><span style="color: #007700">= <<<EOF<br /></span><span style="color: #DD0000">Subject: =?UTF-8?B?UHLDvGZ1bmcgUHLDvGZ1bmc=?=<br />To: example@example.com<br />Date: Thu, 1 Jan 1970 00:00:00 +0000<br />Message-Id: <example@example.com><br />Received: from localhost (localhost [127.0.0.1]) by localhost<br /> with SMTP id example for <example@example.com>;<br /> Thu, 1 Jan 1970 00:00:00 +0000 (UTC)<br /> (envelope-from example-return-0000-example=example.com@example.com)<br />Received: (qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000<br /><br /></span><span style="color: #007700">EOF;<br /><br /></span><span style="color: #0000BB">$headers </span><span style="color: #007700">= </span><span style="color: #0000BB">iconv_mime_decode_headers</span><span style="color: #007700">(</span><span style="color: #0000BB">$headers_string</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #DD0000">"ISO-8859-1"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$headers</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span>
</span>
</code></div>
</div>
<div class="example-contents para"><p>The above example will output:</p></div>
<div class="example-contents screen">
<div class="cdata"><pre>
Array
(
[Subject] => Prüfung Prüfung
[To] => example@example.com
[Date] => Thu, 1 Jan 1970 00:00:00 +0000
[Message-Id] => <example@example.com>
[Received] => Array
(
[0] => from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)
[1] => (qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000
)
)
</pre></div>
</div>
</div><p>
</p>
</div>
<a name="function.iconv-mime-decode-headers.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.iconv-mime-decode.php" class="function" rel="rdfs-seeAlso">iconv_mime_decode()</a> - Decodes a MIME header field</li>
<li class="member"><a href="function.mb-decode-mimeheader.php" class="function" rel="rdfs-seeAlso">mb_decode_mimeheader()</a> - Decode string in MIME header field</li>
<li class="member"><a href="function.imap-mime-header-decode.php" class="function" rel="rdfs-seeAlso">imap_mime_header_decode()</a> - Decode MIME header elements</li>
<li class="member"><a href="function.imap-base64.php" class="function" rel="rdfs-seeAlso">imap_base64()</a> - Decode BASE64 encoded text</li>
<li class="member"><a href="function.imap-qprint.php" class="function" rel="rdfs-seeAlso">imap_qprint()</a> - Convert a quoted-printable string to an 8 bit string</li>
</ul><p>
</p>
</div>
</div><?php manual_footer(); ?>