PHP - imap_utf8_to_mutf7() 函式



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

imap_utf8_to_mutf7() 函式接受 UTF-8 字串作為引數,並將其編碼為 UTF-7 格式。

語法

imap_utf8_to_mutf7($txt);

引數

序號 引數 & 描述
1

txt (必填)

這是一個字串值,表示要編碼的 UTF-8 字串。

返回值

此函式返回一個包含已編碼 UTF-7 字串的字串(成功時)或布林值 FALSE(失敗時)。

PHP 版本

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

示例

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

<html>
   <body>
      <?php
         $utf7 = 'test';
         $res = imap_utf8_to_mutf7($utf7);
         print($res);
      ?>
   </body>
</html>

輸出

這將生成以下輸出。

test

示例

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

<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>"); 
         
         //Creating a mailbox
         $newmailbox = "{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX.test";
         $res = imap_createmailbox($mailbox, imap_utf8_to_mutf7($newmailbox));		 
         
         if($res){
            print("Mailbox created successfully");
         }else{
            print("Error occurred");
         }		 
      ?>
   </body>
</html>

輸出

上述程式生成以下輸出:

Connection established....
Mailbox created successfully
php_function_reference.htm
廣告