Parent Object in php

后端 未结 6 1616
抹茶落季
抹茶落季 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:39

    I'm pretty sure, that PHP does not have something like that.

    Your solution of passing the parent-object to the child is the best solution, I think. You should consider to set your Parent-property only in the constructor of the child to prevent multiple parents from having the same child.

提交回复
热议问题