PHP - imap_qprint() 函式



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

imap_qprint() 函式接受一個表示可列印字串的字串值作為引數,並將其轉換為 8 位字串。

語法

imap_qprint($str);

引數

序號 引數和描述
1

str (必填)

這是一個表示用引號括起來的列印字串的字串值。

返回值

此函式返回給定可列印字串的 8 位字串值。

PHP 版本

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

示例

以下示例演示了imap_qprint() 字串的使用:

<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>");

         $qstring = "This 'is a sample text ' with quotes";
         $res = imap_qprint($qstring);
         print($res);
      ?>
   </body>
</html>

輸出

這將生成以下輸出:

Connection established....
This 'is a sample text ' with quotes

示例

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

<html>
   <body>
      <?php
         //Establishing connection
         $url = "{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX";
         $id = "tutorialspoint.test@gmail.com";
         $pwd = "cohondob_123";
         $imap = imap_open($url, $id, $pwd);
         print("Connection established...."."<br>");
		 
         //Fetching the contents of a message
         print("Contents of the first message: "."<br>");
         $body = imap_body($imap, 1);
         imap_qprint($body);
    
         //Closing the connection
         imap_close($imap);   
      ?>
   </body>
</html>

輸出

這將生成以下輸出:

Connection established....
Contents of the first message:
"UTF-8" #sample_mail1 --000000000000a0d34e05b24373f4 Content-Type: text/h 
php_function_reference.htm
廣告