note 112427 added to reflectionclass.getparentclass
| From: | isaac dot z dot foster at gmail dot com | Date: | Sat, 15 Jun 2013 21:02:12 +0000 |
| Subject: | note 112427 added to reflectionclass.getparentclass | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-195232@lists.php.net to get a copy of this message | ||
Quick correction, the code for getting all parent classes below has a "typo", you need to
reset the $class variable to the parent class instance, otherwise it just endlessly loops:
$class = new ReflectionClass('classname');
$parents = array();
while ($parent = $class->getParentClass()) {
$parents[] = $parent->getName();
$class = $parent;
}
echo "Parents: " . implode(", ", $parents);
----
Server IP: 69.147.83.199
Probable Submitter: 108.21.113.15
----
Manual Page -- http://php.net/manual/en/reflectionclass.getparentclass.php
Edit -- https://master.php.net/note/edit/112427
Del: integrated -- https://master.php.net/note/delete/112427/integrated
Del: useless -- https://master.php.net/note/delete/112427/useless
Del: bad code -- https://master.php.net/note/delete/112427/bad+code
Del: spam -- https://master.php.net/note/delete/112427/spam
Del: non-english -- https://master.php.net/note/delete/112427/non-english
Del: in docs -- https://master.php.net/note/delete/112427/in+docs
Del: other reasons-- https://master.php.net/note/delete/112427
Reject -- https://master.php.net/note/reject/112427
Search -- https://master.php.net/manage/user-notes.php