note 83957 added to language.oop5.reflection
| From: | meecrob at k42b3 dot com | Date: | Fri, 20 Jun 2008 10:47:17 +0000 |
| Subject: | note 83957 added to language.oop5.reflection | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-140616@lists.php.net to get a copy of this message | ||
When your class extends a parent class you maybe want the name
of them. Using getParentClass() is maybe a bit confusing. When
you want the name as string try the following.
<?php
$class = new ReflectionClass('whatever');
$parent = (array) $class->getParentClass();
if(array_key_exists('name', $parent))
{
# name of the parent class
$parent = parent['name'];
}
else
{
# no parent class avaible
$parent = false;
}
?>
When you turn getParentClass() to an array it will result either
array(0 => false) when no parent class exist or
array('name' => 'name of the parent class'). Tested on PHP 5.2.4
----
Server IP: 212.124.37.9
Probable Submitter: 80.132.126.23
----
Manual Page -- http://www.php.net/manual/en/language.oop5.reflection.php
Edit -- https://master.php.net/note/edit/83957
Del: integrated -- https://master.php.net/note/delete/83957/integrated
Del: useless -- https://master.php.net/note/delete/83957/useless
Del: bad code -- https://master.php.net/note/delete/83957/bad+code
Del: spam -- https://master.php.net/note/delete/83957/spam
Del: non-english -- https://master.php.net/note/delete/83957/non-english
Del: in docs -- https://master.php.net/note/delete/83957/in+docs
Del: other reasons-- https://master.php.net/note/delete/83957
Reject -- https://master.php.net/note/reject/83957
Search -- https://master.php.net/manage/user-notes.php