<?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 => 'ja',
  ),
  'this' => 
  array (
    0 => 'function.iconv-mime-decode-headers.php',
    1 => 'iconv_mime_decode_headers',
    2 => '複数の MIME ヘッダフィールドを一度にデコードする',
  ),
  'up' => 
  array (
    0 => 'ref.iconv.php',
    1 => 'iconv 関数',
  ),
  'prev' => 
  array (
    0 => 'function.iconv-mime-decode.php',
    1 => 'iconv_mime_decode',
  ),
  'next' => 
  array (
    0 => 'function.iconv-mime-encode.php',
    1 => 'iconv_mime_encode',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/iconv/functions/iconv-mime-decode-headers.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<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, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">iconv_mime_decode_headers</span> &mdash; <span class="dc-title">複数の <code class="literal">MIME</code> ヘッダフィールドを一度にデコードする</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.iconv-mime-decode-headers-description">
  <h3 class="title">説明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>iconv_mime_decode_headers</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$headers</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$mode</code><span class="initializer"> = 0</span></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$encoding</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   複数の <code class="literal">MIME</code> ヘッダフィールドを一度にデコードします。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.iconv-mime-decode-headers-parameters">
  <h3 class="title">パラメータ</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">headers</code></dt>
     <dd>
      <p class="para">
       エンコードされたヘッダを表す文字列。
      </p>
     </dd>
    
    
     <dt><code class="parameter">mode</code></dt>
     <dd>
      <p class="para">
       <code class="parameter">mode</code> は、<span class="function"><strong>iconv_mime_decode_headers()</strong></span>
       が不正な形式の <code class="literal">MIME</code> ヘッダフィールドに遭遇した場合の
       振る舞いを定義します。以下のビットマスクの組み合わせで指定が可能です。
       <table class="doctable table">
        <caption><strong><span class="function"><strong>iconv_mime_decode_headers()</strong></span> で指定できるビットマスク</strong></caption>
        
         <thead>
          <tr>
           <th>値</th>
           <th>定数名</th>
           <th>説明</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr>
           <td>1</td>
           <td>ICONV_MIME_DECODE_STRICT</td>
           <td>
            指定すると、ヘッダは <a href="https://datatracker.ietf.org/doc/html/rfc2047" class="link external">&raquo;&nbsp;RFC2047</a>
            で定義されている標準に完全準拠する形式でデコードされます。
            このオプションはデフォルトでは無効になっています。なぜなら、世の中には
            おかしなメールソフトが多く存在し、それらは規格に従わずに間違った
            <code class="literal">MIME</code> ヘッダを生成するからです。
           </td>
          </tr>

          <tr>
           <td>2</td>
           <td>ICONV_MIME_DECODE_CONTINUE_ON_ERROR</td>
           <td>
            指定すると、<span class="function"><strong>iconv_mime_decode_headers()</strong></span>
            は文法的なエラーを無視し、デコード作業を継続します。
           </td>
          </tr>

         </tbody>
        
       </table>

      </p>
     </dd>
    
    
     <dt><code class="parameter">encoding</code></dt>
     <dd>
      <p class="para">
       オプションの <code class="parameter">encoding</code> パラメータは、結果の
       文字セットを指定します。指定されなかった場合、もしくは <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> の場合は
       <a href="iconv.configuration.php" class="link">iconv.internal_encoding</a>
       が用いられます。
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.iconv-mime-decode-headers-returnvalues">
  <h3 class="title">戻り値</h3>
  <p class="para">
   成功した場合は連想配列を返します。その中身には
   <code class="parameter">headers</code> で指定した
   <code class="literal">MIME</code> ヘッダフィールドがすべて含まれています。
   デコード中にエラーが発生した場合は <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> を返します。
  </p>
  <p class="para">
   連想配列の個々のキーがフィールド名を表し、対応する要素がフィールドの
   値を表します。同じ名前のフィールドが複数存在する場合は、
   <span class="function"><strong>iconv_mime_decode_headers()</strong></span> が自動的に連番つきの
   配列をつくり、出現順にその配列に入れられます。
   フィールド名は、<em>大文字小文字を区別しない</em> ことに注意して下さい。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.iconv-mime-decode-headers-changelog">
  <h3 class="title">変更履歴</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>バージョン</th>
      <th>説明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">encoding</code> は、nullable になりました。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.iconv-mime-decode-headers-examples">
  <h3 class="title">例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>例1 <span class="function"><strong>iconv_mime_decode_headers()</strong></span> の例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$headers_string </span><span style="color: #007700">= &lt;&lt;&lt;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: &lt;example@example.com&gt;<br />Received: from localhost (localhost [127.0.0.1]) by localhost<br />    with SMTP id example for &lt;example@example.com&gt;;<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">?&gt;</span></span></code></div>
     </div>

     <div class="example-contents"><p>上の例の出力は以下となります。</p></div>
     <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Array
(
    [Subject] =&gt; Pr?ung Pr?ung
    [To] =&gt; example@example.com
    [Date] =&gt; Thu, 1 Jan 1970 00:00:00 +0000
    [Message-Id] =&gt; &lt;example@example.com&gt;
    [Received] =&gt; Array
        (
            [0] =&gt; from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for &lt;example@example.com&gt;; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)
            [1] =&gt; (qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000
        )

)</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.iconv-mime-decode-headers-seealso">
  <h3 class="title">参考</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.iconv-mime-decode.php" class="function" rel="rdfs-seeAlso">iconv_mime_decode()</a> - MIME ヘッダフィールドをデコードする</span></li>
    <li><span class="function"><a href="function.mb-decode-mimeheader.php" class="function" rel="rdfs-seeAlso">mb_decode_mimeheader()</a> - MIME ヘッダフィールドの文字列をデコードする</span></li>
    <li><span class="function"><a href="function.imap-mime-header-decode.php" class="function" rel="rdfs-seeAlso">imap_mime_header_decode()</a> - MIME ヘッダ要素をデコードする</span></li>
    <li><span class="function"><a href="function.imap-base64.php" class="function" rel="rdfs-seeAlso">imap_base64()</a> - BASE64 でエンコードされたテキストをデコードする</span></li>
    <li><span class="function"><a href="function.imap-qprint.php" class="function" rel="rdfs-seeAlso">imap_qprint()</a> - quoted-printable 文字列を 8 ビット文字列に変換する</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>