note 58060 added to function.class-parents
| From: | TJ | Date: | Sat, 22 Oct 2005 20:19:33 +0000 |
| Subject: | note 58060 added to function.class-parents | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-97421@lists.php.net to get a copy of this message | ||
When a class has no parent class this function returns its own class name as parent, rather than an
empty array as you might expect.
So a super-class and it's first sub-class will both see the same result from a call to
class_parents($this);
This means finding out whether a class is the top-most super-class in an inheritence chain requires
more work to determine if it is the root of a heirachy.
$parents = class_parents($this);
if(count($parents==1) && $parents[get_class()] == get_class()) {
echo 'This is a base class.';
}
else
echo 'This is a sub-class.';
----
Manual Page -- http://www.php.net/manual/en/function.class-parents.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58060
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58060&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58060&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58060&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58060&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58060&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58060&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58060&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58060&report=yes
Search -- http://master.php.net/manage/user-notes.php