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. php获取访客所在城市名称代码

    php获取访客所在城市名称代码,采用纯真QQ IP数据库,想要使用最新版IP数据库可到纯真官网获

  2. 后盾网ThinkPHP教程许愿墙及后台管理模版

    后盾网ThinkPHP教程许愿墙及后台管理模版,在网上找了一圈没找到,后来在论坛里给找到了,分享出来和大家一起学习。 打包下载: 后盾网ThinkPHP教程许愿墙及后台管理模版 ─许愿墙及后台管理模版 ├─Admin │ │ .DS_Store │ │ index.html │ │ login.ht

  3. phpMiniAdmin轻量级MySQL在线管理工具,单文件php

    phpminiadmin - 极其轻量级替代沉重的phpMyAdmin可快速方便地访问MySQL数据库。 相反,庞大的安装phpMyAdmin的(?11Mb的),并试图找出如何使用它所有的功能, 只是上传一个?30KB的文件,它就能使用了! 下载地址: http://phpminiadmin.sourceforge.net/ 然

  4. dedecms中提取的zip压缩文件操作类zip.class.php

    从织梦DeDeCMS中提取的zip压缩文件操作类,包含zip文件压缩、解压缩、添加文件到压缩包中等多个实用的函数,注释详细方便使用。 下载: dedecms中提取的zip压缩文件操作类zip.class.php 包含的函数和简单的使用方法: 1.函数get_List($zip_name) ,函数作用

  5. PHP强制下载代码

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

随机推荐

  1. php获取访客所在城市名称代码

    php获取访客所在城市名称代码,采用纯真QQ IP数据库,想要使用最新版IP数据库可到纯真官网获

  2. 后盾网ThinkPHP教程许愿墙及后台管理模版

    后盾网ThinkPHP教程许愿墙及后台管理模版,在网上找了一圈没找到,后来在论坛里给找到了,分享出来和大家一起学习。 打包下载: 后盾网ThinkPHP教程许愿墙及后台管理模版 ─许愿墙及后台管理模版 ├─Admin │ │ .DS_Store │ │ index.html │ │ login.ht

  3. phpMiniAdmin轻量级MySQL在线管理工具,单文件php

    phpminiadmin - 极其轻量级替代沉重的phpMyAdmin可快速方便地访问MySQL数据库。 相反,庞大的安装phpMyAdmin的(?11Mb的),并试图找出如何使用它所有的功能, 只是上传一个?30KB的文件,它就能使用了! 下载地址: http://phpminiadmin.sourceforge.net/ 然

  4. dedecms中提取的zip压缩文件操作类zip.class.php

    从织梦DeDeCMS中提取的zip压缩文件操作类,包含zip文件压缩、解压缩、添加文件到压缩包中等多个实用的函数,注释详细方便使用。 下载: dedecms中提取的zip压缩文件操作类zip.class.php 包含的函数和简单的使用方法: 1.函数get_List($zip_name) ,函数作用

  5. PHP强制下载代码

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