PHP get_parent_class

 1 <?php
 2 class D
 3 {
 4 }
 5 
 6 class A extends D
 7 {
 8 
 9 }
10 
11 class B extends  A
12 {
13 }
14 
15 
16 function getAncestor($class){
17     $parent = get_parent_class($class);
18     if($parent){
19         echo $parent ."\n";
20         getAncestor($parent);
21     }
22 }
23 
24 getAncestor('B');

 

posted @ 2017-07-12 10:19  GoodByeZ  阅读(257)  评论(0编辑  收藏  举报