phpQuery::unloadDocuments PHP Method

unloadDocuments() public static method

Unloades all or specified document from memory.
public static unloadDocuments ( $id = null )
    public static function unloadDocuments($id = null)
    {
        if (isset($id)) {
            if ($id = self::getDocumentID($id)) {
                unset(self::$documents[$id]);
            }
        } else {
            foreach (self::$documents as $k => $v) {
                unset(self::$documents[$k]);
            }
        }
    }

Usage Example

Example #1
0
 function getBody()
 {
     if ($this->parts && $this->body === null) {
         foreach ($this->parts as $part) {
             $partNo = $part['partNo'];
             $encoding = $part['encoding'];
             $charset = $part['charset'];
             $body = imap_fetchbody($this->message->getMailbox(), $this->message->getUID(), $partNo, FT_UID);
             $body = BrIMAP::decode($body, $encoding);
             if ($charset) {
                 $body = @iconv($charset, 'UTF-8', $body);
             }
             $body = trim($body);
             $body = preg_replace('~<head[^>]*?>.*?</head>~ism', '', $body);
             $body = preg_replace('~<meta[^>]*?>~ism', '', $body);
             $body = preg_replace('~<base[^>]*?>~ism', '', $body);
             $body = preg_replace('~<style[^>]*?>.*?</style>~ism', '', $body);
             if ($this->isHTML && $body) {
                 try {
                     $doc = phpQuery::newDocument($body);
                     $bodyTag = $doc->find('body');
                     if ($bodyTag->length() > 0) {
                         $body = trim(pq($bodyTag)->html());
                     } else {
                         $body = trim($doc->html());
                     }
                     phpQuery::unloadDocuments();
                 } catch (Exception $e) {
                 }
             }
             $this->body .= $body;
         }
     }
     return $this->body;
 }
All Usage Examples Of phpQuery::unloadDocuments