note 89096 added to function.get-called-class
| From: | a dot cudbard-bell at sussex dot ac dot uk | Date: | Sat, 21 Feb 2009 18:03:17 +0000 |
| Subject: | note 89096 added to function.get-called-class | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-150921@lists.php.net to get a copy of this message | ||
Here's a simple way of getting the inheritance tree of a class, no matter which class the
function was actually defined in. Will work as a static function method too.
---
class A {
public function get_class_tree(){
$cur_class = get_called_class();
do {
echo $cur_class;
}
while($cur_class = get_parent_class($cur_class));
}
}
class B {
}
class C {
}
$foo = new C();
$foo->get_class_tree();
---
CBA
----
Server IP: 92.48.74.199
Probable Submitter: 94.193.228.11
----
Manual Page -- http://www.php.net/manual/en/function.get-called-class.php
Edit -- https://master.php.net/note/edit/89096
Del: integrated -- https://master.php.net/note/delete/89096/integrated
Del: useless -- https://master.php.net/note/delete/89096/useless
Del: bad code -- https://master.php.net/note/delete/89096/bad+code
Del: spam -- https://master.php.net/note/delete/89096/spam
Del: non-english -- https://master.php.net/note/delete/89096/non-english
Del: in docs -- https://master.php.net/note/delete/89096/in+docs
Del: other reasons-- https://master.php.net/note/delete/89096
Reject -- https://master.php.net/note/reject/89096
Search -- https://master.php.net/manage/user-notes.php