有没有人有关于在CodeIgniter中使用phpQuery的方法和教程?
我这样问是因为我想操作某些css属性并交换出某些css值。我可以用JavaScript来做这件事,但是混合PHP和JavaScript是很困难的,所以这意味着要找到一种方法来操纵HTML和css来做这件事。希望你们都能帮上忙。
因此,我希望加载phpquery并像使用其他库一样使用它
$this->load->libary('phpquery');
$this->phpquery->pq('div > p')->findall();发布于 2012-11-02 07:57:06
通过使用onefile版本的phpQuery作为助手,我让phpQuery在我当前的CodeIgniter项目中工作。
安装
phpQuery下载phpQuery-onefile.zip
/your/ci/proj/application/helpers/phpQuery_helper.php
用法
这是一个非常基本的例子,我正在工作。
//to load in a controller
$this->load->helper('phpQuery');
//I'm using phpQuery in one of my libraries. So, load like this..
$ci =& get_instance();
$ci->load->helper('phpQuery');
//now use phpQuery like normal.
phpQuery::newDocumentHTML('<div id="test">This is a test.</div');
$testElement = pq('#test');
echo $testElement->html(); //This is a test.另一个选择
您也可以只使用常规的旧include_once('path/to/phpQuery-onefile.php');
发布于 2012-07-19 22:13:46
你有没有尝试过PHP的DomDocument类?
http://php.net/manual/en/class.domdocument.php
这应该有点用处吧?
https://stackoverflow.com/questions/11541966
复制相似问题