如何在php中获取类的所有子类 [英] how to obtain all subclasses of a class in php
本文介绍了如何在php中获取类的所有子类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在php中获取给定类的所有子类?
Is it possible to get all subclasses of given class in php?
推荐答案
function getSubclassesOf($parent) {
$result = array();
foreach (get_declared_classes() as $class) {
if (is_subclass_of($class, $parent))
$result[] = $class;
}
return $result;
}
巧合的是,此实现正是 Vadim关联的问题.
Coincidentally, this implementation is exactly the one given in the question linked to by Vadim.
这篇关于如何在php中获取类的所有子类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文