本文整理匯總了PHP中phpQuery::find方法的典型用法代碼示例。如果您正苦於以下問題:PHP phpQuery::find方法的具體用法?PHP phpQuery::find怎麽用?PHP phpQuery::find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類phpQuery
的用法示例。
在下文中一共展示了phpQuery::find方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: pq
/**
* Enter description here...
*
* @return false|phpQuery|queryTemplatesFetch|queryTemplatesParse|queryTemplatesPickup
*/
public static function pq($arg1, $context = null)
{
// TODO support DOMNodes as $context, find out ownerDocument, search loaded DOMs
if (!$context) {
$domId = self::$lastDomId;
} else {
if ($context instanceof self) {
$domId = $context->domId;
} else {
if ($context instanceof DOMDOCUMENT) {
foreach (phpQuery::$documents as $id => $document) {
if ($context->isSameNode($document['document'])) {
$domId = $id;
}
}
if (!$domId) {
throw new Exception('Orphaned DOMNode');
// $domId = self::newDocument($context);
}
} else {
if ($context instanceof DOMNODE) {
foreach (phpQuery::$documents as $id => $document) {
if ($context->ownerDocument->isSameNode($document['document'])) {
$domId = $id;
}
}
if (!$domId) {
throw new Exception('Orphaned DOMNode');
// $domId = self::newDocument($context->ownerDocument);
}
} else {
$domId = $context;
}
}
}
}
if ($arg1 instanceof self) {
/**
* Return $arg1 or import $arg1 stack if document differs:
* pq(pq('<div/>'))
*/
if ($arg1->domId == $domId) {
return $arg1;
}
$phpQuery = new phpQuery($domId);
$phpQuery->elements = array();
foreach ($arg1->elements as $node) {
$phpQuery->elements[] = $phpQuery->DOM->importNode($node, true);
}
return $phpQuery;
} else {
if ($arg1 instanceof DOMNODE || is_array($arg1) && isset($arg1[0]) && $arg[0] instanceof DOMNODE) {
/**
* Wrap DOM nodes with phpQuery object, import into document when needed:
* pq(array($domNode1, $domNode2))
*/
$phpQuery = new phpQuery($domId);
if (!$arg1 instanceof DOMNODELIST && !is_array($arg1)) {
$arg1 = array($arg1);
}
$phpQuery->elements = array();
foreach ($arg1 as $node) {
$phpQuery->elements[] = !$node->ownerDocument->isSameNode($phpQuery->DOM) ? $phpQuery->DOM->importNode($node, true) : $node;
}
return $phpQuery;
} else {
if (self::isMarkup($arg1)) {
/**
* Import HTML:
* pq('<div/>')
*/
$phpQuery = new phpQuery($domId);
$phpQuery->importMarkup($arg1);
return $phpQuery;
} else {
/**
* Run CSS query:
* pq('div.myClass')
*/
$phpQuery = new phpQuery($domId);
if ($context && $context instanceof self) {
$phpQuery->elements = $context->elements;
} else {
if ($context && $context instanceof DOMNODELIST) {
$phpQuery->elements = array();
foreach ($context as $node) {
$phpQuery->elements[] = $node;
}
} else {
if ($context && $context instanceof DOMNODE) {
$phpQuery->elements = array(DOMNODE);
}
}
}
return $phpQuery->find($arg1);
//.........這裏部分代碼省略.........