I have class Mercedes and it has parent Car and Car has parent Main.
I want to get all parents from Mercedes Class
Mercedes extends Car
Car extends Main
output should be something like this mercedes<-Car<-Main
This would do:
function GetAllParents(instance) {
return get_class(instance) . '<-' .
implode('<-', array_reverse(class_parents(instance)));
}
Outputs all in the right order:
Mercedes<-Car<-Main
See documentation:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With