【发布时间】:2012-05-02 22:29:53
【问题描述】:
假设我有以下代码。
class A {
function one() {
return $this;
}
}
class B extends A {
function two() {
return $this;
}
}
有什么方法可以让我使用父类中的函数进行方法链? 比如……
$b = new B();
$b->one()->two();
【问题讨论】:
-
这有什么问题?它适用于我在那里添加一些回声,您将看到正确顺序的输出。
-
@Gohn67 - 你的权利,.. 所以在我的真实方法中肯定有其他问题,页面不断崩溃。我想我应该先测试一下这个简化版本。 :) 谢谢!
标签: php method-chaining