Codeigniter中使用SimpleHTMLDOM

Cod*_*alk 1 php customization parsing codeigniter

我的问题是,我正在寻找使用Php Simple Html Dom Parser的方法,但是该文件似乎只是一个集合,functions而不是class SomeClass{}声明,因此很难像我声明后那样将其作为自定义内容 嵌入library到codeigniter中。 。$ this-> load-> library('someclass');

我已将此代码放在用于简单HTML Dom解析器的pastebin中:http : //pastebin.com/0rR6Kiex

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

class MyClass{
   ## contents of pastebin here

}
Run Code Online (Sandbox Code Playgroud)

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

$this->load->library('myclass');
$thus->myclass->fetchlinks();
Run Code Online (Sandbox Code Playgroud)

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

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

Bry*_*ito 5

由于它具有一系列功能,为什么不把它作为一个助手呢?

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

$this->myclass->fetchlinks();