请教ci增加一个类呢?
因为自己增加一个树形图的类,不知怎么在ci里面增加呢?可以方便调用的? 仔细阅读:http://codeigniter.org.cn/user_guide/general/creating_libraries.html hex这么晚也在线啊。谢谢。 仔细阅读:Hex 发表于 2011-4-15 01:37 http://codeigniter.org.cn/forums/images/common/back.gif
class Person{
function __construct($name){
$this->name = $name;
}
function say(){
return $this->name;
}
}
$person = new Person('凉快赶快赶快');
$a = $person->say();
假设我的类原本是这样的。
那么在ci里面我应该这样写呢?
$this->load->library('person');
$tree = $this->person->__construct('凉快赶快赶快');
$a = $this->person->say('');
大体正确,不过类的构造函数不能直接调用,会自动调用的。
类库传参,手册有明确说明,你仔细看一下。
页:
[1]