crezd Posted March 4, 2007 Share Posted March 4, 2007 subj... Link to comment https://forums.phpfreaks.com/topic/41095-how-can-i-get-name-of-the-child-class-from-parent-class/ Share on other sites More sharing options...
Barand Posted March 4, 2007 Share Posted March 4, 2007 try <?php class a { public $val; function __construct() { $this->val = 1; } function list_children() { $classes = get_declared_classes(); foreach ($classes as $c) { if (is_subclass_of($c, 'a')) { echo $c,'<br>'; } } } } class b extends a { function __construct() { $this->val = 2; } } class c { public $val; } class d extends a { function __construct() { $this->val = 3; } } a::list_children(); ?> Link to comment https://forums.phpfreaks.com/topic/41095-how-can-i-get-name-of-the-child-class-from-parent-class/#findComment-199016 Share on other sites More sharing options...
crezd Posted March 4, 2007 Author Share Posted March 4, 2007 thanks a lot! Link to comment https://forums.phpfreaks.com/topic/41095-how-can-i-get-name-of-the-child-class-from-parent-class/#findComment-199021 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.