php,我需要来自父对象的子对象,如何?
class Parent
{
public function exec()
{
// here I need the child object!
}
}
class Child extends Parent
{
public function exec()
{
// something
parent::exec();
}
}
如您所见,我需要父对象的子对象。我怎样才能达到它?
class Parent
{
public function exec()
{
// here I need the child object!
}
}
class Child extends Parent
{
public function exec()
{
// something
parent::exec();
}
}
as you can see, I need the child object from the parent. How can I reach it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将孩子作为参数传递:
但这很少需要,因此可能有更好的方法 你想要做什么。
You can pass the child as an argument:
This is rarely needed though, so there might be a better way to do what you're trying to do.