Whats the difference between using pq(selector) and $doc[selector]

49 views
Skip to first unread message

Dimas

unread,
Jan 12, 2010, 1:26:02 PM1/12/10
to phpQuery
$doc = phpQuery::newDocumentHTML($contents);

$doc[SELECTOR]

pq(SELECTOR)

...

Maybe I'll answer my own question here, is pq default for the CURRENT
active document, if you were using multiple documents then it would be
best to use $doc[SELECTOR]?

Tobiasz Cudnik

unread,
Jan 27, 2010, 2:51:28 AM1/27/10
to phpQuery
Besides the difference you've mentioned, there's also very important
thing - pq() functions accepts various types of arguments, eg:
pq('<div/>')
will create new DOM object.

While array-like usage $obj['selector'] is direct shortcut to $obj-
>find('selector'); You can also use it to make assignments, then inner
part of selected element will take new content.

Reply all
Reply to author
Forward
0 new messages