PHP - imap_get_quotaroot() 函式



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

**imap_get_quotaroot()** 函式接受一個表示 IMAP 流的資源值,一個表示 quota_root 的字串值作為引數,並檢索每個使用者的配額級別設定。

語法

imap_get_quotaroot($imap_stream, $quota_root);

引數

序號 引數及說明
1

imap_stream (必填)

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

2

quota_root (必填)

這是一個表示 quota_root 的字串值,它將採用 user.name 的形式,其中 name 是郵箱的名稱。

返回值

此函式返回一個包含資訊的陣列值。

PHP 版本

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

示例

以下示例演示了 **imap_get_quotaroot()** 函式的使用方法:

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

         $quota = imap_get_quotaroot($imap, "INBOX");
         print_r($quota);
         //Closing the connection
         imap_close($imap);   
      ?>
   </body>
</html>

輸出

這將生成以下輸出:

Connection established....
Array ( 
   [usage] => 349 [limit] => 15728640 [STORAGE] => 
   Array ( [usage] => 349 [limit] => 15728640 ) 
)

示例

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

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

         $quota = imap_get_quotaroot($imap, "INBOX");
         if (is_array($quota)) {
            $storage = $quota['STORAGE'];
            print("Usage: " . $storage['usage']);
            print("<br>");
            print("Limit: " . $storage['limit']);
            print("<br><br>");
         }
         //Closing the connection
         imap_close($imap);   
      ?>
   </body>
</html>

輸出

這將生成以下輸出:

Connection established....
Usage: 349
Limit: 15728640
php_function_reference.htm
廣告