PHP/Reflection/get declared interfaces

Материал из Web эксперт
Перейти к: навигация, поиск

get_declared_interfaces( ) returns an array of all the interfaces currently available to you

 
<?
    interface Boat {
            function sink( );
            function scuttle( );
            function dock( );
    }
    interface Plane extends Boat {
            function takeoff( );
            function land( );
            function bailout( );
    }
    class Boatplane implements Plane {
            public function sink( ) { }
            public function scuttle( ) { }
            public function dock( ) { }
            public function takeoff( ) { }
            public function land( ) { }
            public function bailout( ) { }
    }
    $obj = new Boatplane( );
?>



Listing Currently Loaded Interfaces and Classes

 
obtain lists of the interfaces and classes currently loaded with the functions get_declared_interfaces() and get_declared_classes(), respectively. 
<?
printf("<p>Interfaces currently available: %s</p>", 
implode(", ", get_declared_interfaces())); 
printf("<p>Classes currentlyavailable: %s</p>", 
implode(", ", get_declared_classes())); 
?>