【问题标题】:SimpleHTMLDOM use in Codeigniter在 Codeigniter 中使用 SimpleHTMLDOM
【发布时间】:2013-01-16 01:58:34
【问题描述】:

我的问题是,我希望使用 Php Simple Html Dom Parser 但是,该文件似乎只是一组 functions 而不是 class SomeClass{} 声明,因此很难嵌入为 自定义 library 在 codeigniter 中,就像我声明它之后一样。 $this->load->library('someclass');

我已将此代码放入 Simple Html Dom Parser 的 pastebin 中: http://pastebin.com/0rR6Kiex

我想知道如何通过我定义的类轻松地使所有这些功能可用:

class MyClass{
   ## contents of pastebin here

}

所以我可以在 codeigniter 中加载,例如:

$this->load->library('myclass');
$thus->myclass->fetchlinks();

目前,我正在尝试手动要求一个 php 文件,这有点违背了使用 codeigniter 的意义:

function fetchlinks(){
    ## include the Simpledom framework #########################################################
    include "localhost/mysite/assets/php/Simpledom.php" or die('Error occured on page');   #
}

【问题讨论】:

标签: php codeigniter parsing customization


【解决方案1】:

既然是一组函数,为什么不把它当成助手呢?

$this->load->helper('myclass');

$this->myclass->fetchlinks();

【讨论】:

  • 这么简单,我没想到。谢谢你的建议,我试试这个!
猜你喜欢
  • 1970-01-01
  • 2017-01-27
  • 1970-01-01
  • 2011-08-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-01-18
  • 1970-01-01
相关资源
最近更新 更多