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');
学习记录,方便复习