我的问题是,我希望使用Php简单Html Dom解析器,但是,该文件似乎只是一组functions,而不是class SomeClass{}声明,因此很难像声明后那样在代码点火器中嵌入自定义library。$this->load->库(‘someclass’);
对于简单的Html:http://pastebin.com/0rR6Kiex,我将这段代码放入pastebin中。
我想知道如何通过定义如下的类轻松地使所有这些函数可用:
class MyClass{
## contents of pastebin here
}所以我可以加载代码点火器,比如:
$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'); #
}发布于 2013-01-16 05:43:21
既然它是一组函数,为什么不把它当作一个助手呢?
$this->load->helper('myclass');
$this->myclass->fetchlinks();
https://stackoverflow.com/questions/14350262
复制相似问题