#21871 [Com]: class_exists() doesn't work for nested classes
| From: | thekid at thekid dot de | Date: | Sat, 19 Apr 2003 17:02:51 +0000 |
| Subject: | #21871 [Com]: class_exists() doesn't work for nested classes | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-37906@lists.php.net to get a copy of this message | ||
ID: 21871
Comment by: thekid at thekid dot de
Reported By: yoglets at hotmail dot com
Status: Verified
Bug Type: Zend Engine 2 problem
Operating System: RedHat 7.3
PHP Version: 5CVS-2003-01-24 (dev)
New Comment:
As nested class no longer exist, I assume this can be closed.
Previous Comments:
------------------------------------------------------------------------
[2003-01-24 19:34:19] yoglets at hotmail dot com
Given an instance of a nested class, get_class() returns the "::
separated" name for it, as expected. However, passing that value right
back to class_exists() always fails -- i.e., returns FALSE.
<?php
class Foo {
class Bar {
}
}
$x = new Foo::Bar;
if (class_exists(get_class($x))) {
echo "x is looking good\n";
} else {
echo "x is apparently not itself\n";
}
?>
In addition, get_declared_classes() will only report on the top-level
classes, leaving out any that are nested. In this example, it would
report "Foo", but not "Foo::Bar".
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=21871&edit=1