1

Possible Duplicate:
php: determining class hierarchy of an object at runtime

Is there a way to get a list of parent classes for a certain class?

For example:

class a{ 
    public function getParentsList(){...}
}

class b extends a{}

class c extends b{}

$c=new c;

var_dump($c->getParentsList());

should print array(a,b)

VLAZ
  • 26,331
  • 9
  • 49
  • 67
Catalin
  • 858
  • 5
  • 16

2 Answers2

3

You may use the reflection classes http://www.php.net/manual/en/book.reflection.php

A working example seems to be this one: http://www.php.net/manual/en/reflectionclass.getparentclass.php#100978

Quamis
  • 10,924
  • 12
  • 50
  • 66
1

I've seen an answer to this before:

Answered by michael at getsprink dot -- com on php.net

Brendan Bullen
  • 11,607
  • 1
  • 31
  • 40