$class = new code();$class ->action1()->action2();我看有些方法调用是这么调用的,这是什么原理。
3 回答

慕田峪4524236
TA贡献1875条经验 获得超5个赞
举个示例来说,
$str = 'abc123 ';
echo strlen(trim($str));
链式编程
$str = 'abc123 ';
echo $str->trim()->strlen();

慕侠2389804
TA贡献1719条经验 获得超6个赞
就是你调用action1()的时候 返回的任然是object,当然可以继续调用了,链式调用。
class Test{
public function action1(){
//do something
return $this;
}
}
- 3 回答
- 0 关注
- 497 浏览
添加回答
举报
0/150
提交
取消