PHP - imap_mime_header_decode() 函式



PHP−IMAP 函式可幫助您訪問電子郵件帳戶,IMAP 代表 **I**nternet **M**ail **A**ccess **P**rotocol,使用這些函式,您還可以使用 NNTP、POP3 協議和本地郵箱訪問方法。

**imap_mime_header_decode()** 函式接受一個表示 Mime 文字的字串值作為引數,並解碼給定的標頭。

語法

imap_mime_header_decode($text);

引數

序號 引數和描述
1

text(必填)

這是一個表示 MIME 文字的字串值。

返回值

此函式返回一個包含解碼值的陣列物件。

PHP 版本

此函式首次引入 PHP 4 版本,並在所有後續版本中均有效。

示例

<html>
   <body>
      <?php
         $mime_encoded = 'example: =?UTF-8?B?UHLDvGZ1bmcgUHLDvGZ1bmc=?=';
         $res = imap_mutf7_to_utf8($mime_encoded);
         $decode = imap_mime_header_decode($res);		
         print_r($decode);
         print("<br>");
         print("<br>");
		
         mime_encoded = 'test =?ISO-8859-1?Q?Schl=FCter?=';
         $res = imap_mutf7_to_utf8($mime_encoded);
         $decode = imap_mime_header_decode($res);		
         print_r($decode);
      ?>
   </body>
</html>

輸出

這將生成以下輸出:

Array (
   [0] => stdClass Object ( [charset] => default [text] => example: ) 
   [1] => stdClass Object ( [charset] => UTF-8 [text] => Prüfung Prüfung ) 
)
Array ( 
   [0] => stdClass Object ( [charset] => default [text] => test ) 
   [1] => stdClass Object ( [charset] => ISO-8859-1 [text] => Schl�ter ) 
)

示例

以下示例演示了 imap_mime_header_decode() 函式的使用:

示例

以下是上述函式的另一個示例:

<html>
   <body>
      <?php
         $encode = base64_encode("?utf-8?Q?");
         $text = "=?ks_c_5601-1987?B?";
         $text = $text.$encode."?=";
         $res = imap_mime_header_decode($text);
         print($text);	   
      ?>
   </body>
</html>

輸出

這將生成以下輸出:

=?ks_c_5601-1987?B?P3V0Zi04P1E/?=
php_function_reference.htm
廣告