php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21871 class_exists() doesn't work for nested classes
Submitted: 2003-01-24 19:34 UTC Modified: 2003-04-19 16:14 UTC
From: yoglets at hotmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5CVS-2003-01-24 (dev) OS: RedHat 7.3
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: yoglets at hotmail dot com
New email:
PHP Version: OS:

 

 [2003-01-24 19:34 UTC] 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".

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-19 12:02 UTC] thekid at thekid dot de
As nested class no longer exist, I assume this can be closed.
 [2003-04-19 16:14 UTC] helly@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

No more support for nested classes.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Oct 18 06:01:29 2024 UTC