PHP - imap_utf7_decode() 函式



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

**imap_utf7_decode()** 函式接受一個 UTF-7 編碼的字串作為引數並對其進行解碼。

語法

imap_utf7_decode($txt);

引數

序號 引數 & 描述
1

txt (必填)

這是一個表示 UTF-7 文字的字串值。

返回值

此函式返回一個字串值,其中包含給定文字的解碼值。

PHP 版本

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

示例

以下示例演示了 **imap_utf7_decode()** 函式的用法。

<html>
   <body>
      <?php
         $utf7 = '[Gmail]/&BBIEMAQ2BD0EPgQ1−';
         $res = imap_utf7_decode($utf7);
         print($res);
      ?>
   </body>
</html>

輸出

這將生成以下輸出:

[Gmail]/06=>5

示例

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

<html>
   <body>
      <?php
         $url = "{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX";
         $id = "tutorialspoint.test@gmail.com";
         $pwd = "cohondob_123";
         $mailbox = imap_open($url, $id, $pwd);
         print("Connection established....");
         print("<br>");

         //Retrieving the contents of mail boxes
         $list = imap_getmailboxes($mailbox, $url, "*");
         if (is_array($list)) {
           foreach ($list as $key => $val) {		   
               print("Name: ".imap_utf7_decode($val->name) ."<br>");
            }         
         } else {  }
      ?>
   </body>
</html>

輸出

這將生成以下輸出:

Connection established....
Name: {imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX
php_function_reference.htm
廣告