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获取访客IP代码

    PHP获取访客IP代码,下面是医疗模板库为大家收集整理的获取访客IP的代码: 复制代码 代码如下: ?php function ip() { if(getenv(HTTP_CLIENT_IP) strcasecmp(getenv(HTTP_CLIENT_IP), unknown)) { $ip = getenv(HTTP_CLIENT_IP); } elseif(getenv(HTTP_X_FOR

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

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

  3. php禁止危险函数

    打开php配置文件php.ini,将以下函数禁用。 disable_functions=assert,phpinfo,eval,passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symli

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

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

  5. sublime下ThinkPHP3.2代码自动补全扩展

    应该有不少人用这个编辑器吧,tp3.2的代码自动补全..周末总结了下.需要的可以使用下,,打开sublime-preferences-浏览插件(按B键也可以吧)-会打开一个文件夹,把附件解压放进去就可以了. 下载: sublime下ThinkPHP3.2代码自动补全扩展 如果模版中不能使用,请修改

随机推荐

  1. PHP获取访客IP代码

    PHP获取访客IP代码,下面是医疗模板库为大家收集整理的获取访客IP的代码: 复制代码 代码如下: ?php function ip() { if(getenv(HTTP_CLIENT_IP) strcasecmp(getenv(HTTP_CLIENT_IP), unknown)) { $ip = getenv(HTTP_CLIENT_IP); } elseif(getenv(HTTP_X_FOR

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

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

  3. php禁止危险函数

    打开php配置文件php.ini,将以下函数禁用。 disable_functions=assert,phpinfo,eval,passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symli

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

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

  5. sublime下ThinkPHP3.2代码自动补全扩展

    应该有不少人用这个编辑器吧,tp3.2的代码自动补全..周末总结了下.需要的可以使用下,,打开sublime-preferences-浏览插件(按B键也可以吧)-会打开一个文件夹,把附件解压放进去就可以了. 下载: sublime下ThinkPHP3.2代码自动补全扩展 如果模版中不能使用,请修改