比如tp框架M('table')->where()->limit()->find();
下面这么写为什么会报错
<?php
/**
*
*/
class bb
{
public function fc1(){
}
public function fc2(){
}
public function fc3(){
}
}
$bb = new bb();
$bb->fc1()->fc2()->fc3();
6 回答

慕森卡
TA贡献1806条经验 获得超8个赞
方法里返回当前对象。
<?php
class bb
{
public function fc1(){
return $this;
}
public function fc2(){
return $this;
}
public function fc3(){
return $this;
}
}
$bb = new bb();
$bb->fc1()->fc2()->fc3();

婷婷同学_
TA贡献1844条经验 获得超8个赞
这个链式调用风格。通常在函数中实现某个方法后,返回当前对象.
public function fn1(){
//dosomething
return $this;
}
由于函数返回的是当前的对象,因此有可以调用其他方法。
- 6 回答
- 0 关注
- 465 浏览
添加回答
举报
0/150
提交
取消