phpQuery::createDocumentWrapper PHP Method

createDocumentWrapper() protected static method

..
protected static createDocumentWrapper ( unknown_type $html, $contentType = null, $documentID = null ) : unknown
$html unknown_type
return unknown New DOM ID
    protected static function createDocumentWrapper($html, $contentType = null, $documentID = null)
    {
        if (function_exists('domxml_open_mem')) {
            throw new Exception("Old PHP4 DOM XML extension detected. phpQuery won't work until this extension is enabled.");
        }
        //		$id = $documentID
        //			? $documentID
        //			: md5(microtime());
        $document = null;
        if ($html instanceof DOMDOCUMENT) {
            if (self::getDocumentID($html)) {
                // document already exists in phpQuery::$documents, make a copy
                $document = clone $html;
            } else {
                // new document, add it to phpQuery::$documents
                $wrapper = new DOMDocumentWrapper($html, $contentType, $documentID);
            }
        } else {
            $wrapper = new DOMDocumentWrapper($html, $contentType, $documentID);
        }
        //		$wrapper->id = $id;
        // bind document
        self::$documents[$wrapper->id] = $wrapper;
        // remember last loaded document
        self::selectDocument($wrapper->id);
        return $wrapper->id;
    }

Usage Example

コード例 #1
0
 /**
  * Creates new document from markup.
  * Chainable.
  *
  * @param unknown_type $markup
  * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
  */
 public static function newDocument($markup = null, $contentType = null)
 {
     if (!$markup) {
         $markup = '';
     }
     $documentID = phpQuery::createDocumentWrapper($markup, $contentType);
     return new phpQueryObject($documentID);
 }
All Usage Examples Of phpQuery::createDocumentWrapper