phpQuery下载—包含官方完整使用文档

模板网 2014-10-07

phpQuery下载—包含官方完整使用文档。phpQuery是一个类似jQuery的php网页采集类库,使用方法非常简单。

下载地址:phpQuery下载—包含官方完整使用文档

官方下载地址:https://code.google.com/p/phpquery/

下载压缩包截图:

phpQuery下载—包含官方完整使用文档

官方提供的demo代码:

复制代码 代码如下:
<?php
require('phpQuery/phpQuery.php');
 
// INITIALIZE IT
// phpQuery::newDocumentHTML($markup);
// phpQuery::newDocumentXML();
// phpQuery::newDocumentFileXHTML('test.html');
// phpQuery::newDocumentFilePHP('test.php');
// phpQuery::newDocument('test.xml', 'application/rss+xml');
// this one defaults to text/html in utf8
$doc = phpQuery::newDocument('<div/>');
 
// FILL IT
// array syntax works like ->find() here
$doc['div']->append('<ul></ul>');
// array set changes inner html
$doc['div ul'] = '<li>1</li> <li>2</li> <li>3</li>';
 
// MANIPULATE IT
$li = null;
// almost everything can be a chain
$doc['ul > li']
->addClass('my-new-class')
->filter(':last')
->addClass('last-li')
// save it anywhere in the chain
->toReference($li);
 
// SELECT DOCUMENT
// pq(); is using selected document as default
phpQuery::selectDocument($doc);
// documents are selected when created or by above method
// query all unordered lists in last selected document
$ul = pq('ul')->insertAfter('div');
 
// ITERATE IT
// all direct LIs from $ul
foreach($ul['> li'] as $li) {
// iteration returns PLAIN dom nodes, NOT phpQuery objects
$tagName = $li->tagName;
$childNodes = $li->childNodes;
// so you NEED to wrap it within phpQuery, using pq();
pq($li)->addClass('my-second-new-class');
}
 
// PRINT OUTPUT
// 1st way
print phpQuery::getDocument($doc->getDocumentID());
// 2nd way
print phpQuery::getDocument(pq('div')->getDocumentID());
// 3rd way
print pq('div')->getDocument();
// 4th way
print $doc->htmlOuter();
// 5th way
print $doc;
// another...
print $doc['ul'];

 

相关文章

  1. phpQuery下载—包含官方完整使用文档

    phpQuery下载包含官方完整使用文档。phpQuery是一个类似jQuery的php网页采集类库,使用方法非常简单。 下载地址: phpQuery下载包含官方完整使用文档 官方下载地址: https://code.google.com/p/phpquery/ 下载压缩包截图: 官方提供的demo代码: 复制代码

  2. PHP超好用的整站打包程序 单文件

    给大家推荐一个PHP超好用的整站打包程序 单文件 小巧方便 界面如下: 使用方法: 1、将该程序上传到网站的目录下,如/zip.php ; 2、在浏览器中访问程序 http://www.120muban.com/zip.php ; 3、将出现上图所示界面,可按照提示说明进行相关的操作; 4、点击

  3. MySQL在线管理工具Adminer.php单文件轻量级功能强大

    Adminer(原名phpMinAdmin)是用PHP编写的一个全功能的数据库管理工具。相比phpMyAdmin,它包含一个文件可以部署到目标服务器。管理可用于MySQL、PostgreSQL SQLite,MS SQL,甲骨文,SimpleDB,Elasticsearch MongoDB。

  4. php判断一个页面是否被删除判断返回404

    复制代码 代码如下: ?php function get404($urla){ $headers = get_headers($urla); $htt = $headers[3]; $silingsi = 404; if(stripos($htt,$silingsi,0)== false){ $shoulu = 正常; return $shoulu; break; }else{ $shoulu = 404; return $shoulu; break;

  5. PHP强制下载代码

    PHP在输出文件的时候在一些浏览器上会直接以文本的方式显示在浏览器上,添加一下代码可以强制浏览器下载输出的文件。

随机推荐

  1. phpQuery下载—包含官方完整使用文档

    phpQuery下载包含官方完整使用文档。phpQuery是一个类似jQuery的php网页采集类库,使用方法非常简单。 下载地址: phpQuery下载包含官方完整使用文档 官方下载地址: https://code.google.com/p/phpquery/ 下载压缩包截图: 官方提供的demo代码: 复制代码

  2. PHP超好用的整站打包程序 单文件

    给大家推荐一个PHP超好用的整站打包程序 单文件 小巧方便 界面如下: 使用方法: 1、将该程序上传到网站的目录下,如/zip.php ; 2、在浏览器中访问程序 http://www.120muban.com/zip.php ; 3、将出现上图所示界面,可按照提示说明进行相关的操作; 4、点击

  3. MySQL在线管理工具Adminer.php单文件轻量级功能强大

    Adminer(原名phpMinAdmin)是用PHP编写的一个全功能的数据库管理工具。相比phpMyAdmin,它包含一个文件可以部署到目标服务器。管理可用于MySQL、PostgreSQL SQLite,MS SQL,甲骨文,SimpleDB,Elasticsearch MongoDB。

  4. php判断一个页面是否被删除判断返回404

    复制代码 代码如下: ?php function get404($urla){ $headers = get_headers($urla); $htt = $headers[3]; $silingsi = 404; if(stripos($htt,$silingsi,0)== false){ $shoulu = 正常; return $shoulu; break; }else{ $shoulu = 404; return $shoulu; break;

  5. PHP强制下载代码

    PHP在输出文件的时候在一些浏览器上会直接以文本的方式显示在浏览器上,添加一下代码可以强制浏览器下载输出的文件。