PHP - imap_mutf7_to_utf8() 函式



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

**imap_mutf7_to_utf8()** 函式接受一個表示 UTF-7 格式編碼字串的字串值作為引數,並將給定字串解碼為 UTF-8 格式。

語法

imap_mutf7_to_utf8($str);

引數

序號 引數和描述
1

str (必填)

這是一個字串值,表示 IMAP 流,**imap_open()** 函式的返回值。

返回值

此函式在成功的情況下返回一個包含轉換為 UTF-8 值的字串值,在失敗的情況下返回布林值 FALSE。

PHP 版本

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

示例

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

輸出

這將生成以下輸出:

example: =?UTF-8?B?UHLDvGZ1bmcgUHLDvGZ1bmc=?=
test =?ISO-8859-1?Q?Schl=FCter?=

示例

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

<html>
   <body>
      <?php
         $encode = imap_mutf7_to_utf8("?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??utf-8?Q??=
php_function_reference.htm
廣告