Skip to content

Commit 533ecff

Browse files
author
wq455133
committed
update dir
0 parents  commit 533ecff

File tree

125 files changed

+20279
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+20279
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor/

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Moved from [code.google.com/archive/p/phpquery](https://code.google.com/archive/p/phpquery/)
2+
3+
# phpQuery - pq();
4+
5+
phpQuery is a server-side, chainable, CSS3 selector driven Document Object Model (DOM) API based on jQuery JavaScript Library.
6+
7+
Library is written in PHP5 and provides additional Command Line Interface (CLI).

composer.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "wpollen/phpquery",
3+
"description": ".DomDocument",
4+
"type": "stability",
5+
"license": "mit",
6+
"authors": [
7+
{
8+
"name": "wq455133",
9+
"email": "[email protected]"
10+
}
11+
],
12+
"require": {},
13+
"autoload": {
14+
"files": [
15+
"phpQuery.php"
16+
]
17+
}
18+
}

demo.php

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
require('phpQuery/phpQuery.php');
3+
4+
// INITIALIZE IT
5+
// phpQuery::newDocumentHTML($markup);
6+
// phpQuery::newDocumentXML();
7+
// phpQuery::newDocumentFileXHTML('test.html');
8+
// phpQuery::newDocumentFilePHP('test.php');
9+
// phpQuery::newDocument('test.xml', 'application/rss+xml');
10+
// this one defaults to text/html in utf8
11+
$doc = phpQuery::newDocument('<div/>');
12+
13+
// FILL IT
14+
// array syntax works like ->find() here
15+
$doc['div']->append('<ul></ul>');
16+
// array set changes inner html
17+
$doc['div ul'] = '<li>1</li> <li>2</li> <li>3</li>';
18+
19+
// MANIPULATE IT
20+
$li = null;
21+
// almost everything can be a chain
22+
$doc['ul > li']
23+
->addClass('my-new-class')
24+
->filter(':last')
25+
->addClass('last-li')
26+
// save it anywhere in the chain
27+
->toReference($li);
28+
29+
// SELECT DOCUMENT
30+
// pq(); is using selected document as default
31+
phpQuery::selectDocument($doc);
32+
// documents are selected when created or by above method
33+
// query all unordered lists in last selected document
34+
$ul = pq('ul')->insertAfter('div');
35+
36+
// ITERATE IT
37+
// all direct LIs from $ul
38+
foreach($ul['> li'] as $li) {
39+
// iteration returns PLAIN dom nodes, NOT phpQuery objects
40+
$tagName = $li->tagName;
41+
$childNodes = $li->childNodes;
42+
// so you NEED to wrap it within phpQuery, using pq();
43+
pq($li)->addClass('my-second-new-class');
44+
}
45+
46+
// PRINT OUTPUT
47+
// 1st way
48+
print phpQuery::getDocument($doc->getDocumentID());
49+
// 2nd way
50+
print phpQuery::getDocument(pq('div')->getDocumentID());
51+
// 3rd way
52+
print pq('div')->getDocument();
53+
// 4th way
54+
print $doc->htmlOuter();
55+
// 5th way
56+
print $doc;
57+
// another...
58+
print $doc['ul'];

0 commit comments

Comments
 (0)