#21871 [Opn->Ver]: class_exists() doesn't work for nested classes

From: Date: Thu, 13 Feb 2003 06:54:08 +0000
Subject: #21871 [Opn->Ver]: class_exists() doesn't work for nested classes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-32985@lists.php.net to get a copy of this message
ID: 21871 Updated by: sniper@php.net Reported By: yoglets@hotmail.com -Status: Open +Status: Verified Bug Type: Zend Engine 2 problem Operating System: RedHat 7.3 PHP Version: 5CVS-2003-01-24 (dev) Previous Comments: ------------------------------------------------------------------------ [2003-01-24 19:34:19] yoglets@hotmail.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

« previous php.bugs (#32985) next »