How to get the name of all user classes?

5

The get_declared_classes function ALL classes defined in PHP, both from the internal PHP library and the user's library.

I wanted a function for classes of type: get_defined_functions , which separates PHP core functions of user functions.

I think you can do with Reflection but I believe there is another option.

How to get classes defined by user in PHP?

    
asked by anonymous 25.09.2014 / 23:10

1 answer

3

So far, I have not found another way:

You can do it by Reflection:

        $classes = get_declared_classes();

        foreach($classes as $className){
            $reflection = new \ReflectionClass($className);

            if( $reflection->isUserDefined() ){
                echo $className.'<br>';
            }
        }
    
30.09.2014 / 03:48