Parent Object in php

后端 未结 6 1635
抹茶落季
抹茶落季 2020-12-15 08:57

is there a way to traverse an object to get the parent object data? With \"parent object\" I don\'t mean the parent class, but literally object. Here an example, in a javasc

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-15 09:34

    Passing the parent to the child is the better solution. Though it's a somewhat undesirable symbiotic relationship.

    Should B() have any knowledge of the object it's an attribute of? More than likely not. These are only loosely related via composition.

    Why does B() need to be an attribute of it's parent? Do you need to have this implementation in B() or should it be part of the parent?

提交回复
热议问题