有什么方法可以在 PHP 中确定父类中的子实例?假设我们有以下代码:
class Parent {
public function InstanceOfChild() {
//What to put here to display "Child class is instance of ChildClass123"?
}
}
class ChildClass123 extends Parent {
//Some code here
}
我需要做的(如果可能的话)是创建方法InstanceOfChild()
,它会告诉我子类的实例,因为很多类都可以是我父类的子类,但我想(比如说)记录,哪个子类调用哪些方法. 感谢帮助!