phpQuery::newDocumentFile($htmlFile); //之后
phpQuery::$documents = array();
//或者unset(phpQuery::$documents);
while (true) {
phpQuery::newDocumentFile($htmlFile);
// 处理网页元素...
phpQuery::$documents = array();
echo memory_get_usage() . "\n"; //获取内存消耗量
}
例子:
phpQuery::newDocumentFileXHTML('my-xhtml.html')->find('p');
$ul = pq('ul');
phpQuery :: newDocument($ html,$ contentType = null)//从标记创建新文档。如果没有$ contentType,//则自动检测(基于标记)。如果失败,则使用utf-8中的text / html。
phpQuery :: newDocumentFile($ file,$ contentType = null)//从文件创建新文档。像newDocument()
phpQuery :: newDocumentHTML($ html,$ charset ='utf-8')
phpQuery :: newDocumentXHTML($ html,$ charset ='utf-8')
phpQuery :: newDocumentXML($ html,$ charset ='utf-8')
phpQuery :: newDocumentPHP($ html,$ contentType = null)
phpQuery :: newDocumentFileHTML($ file,$ charset ='utf-8')
phpQuery :: newDocumentFileXHTML($ file,$ charset ='utf-8')
phpQuery :: newDocumentFileXML($ file,$ charset ='utf-8')
phpQuery :: newDocumentFilePHP($ file,$ contentType)
PQ(); 函数相当于jQuery的$(); 。它用于3种类型的东西:1.导入标记1.运行查询1.使用phpQuery对象包装DOMNodes