class Vehicle implements Car, Motorcycle { // Class code here... } $reflectionClass = new ReflectionClass('Vehicle'); $interfaces = $reflectionClass->getInterfaces(); // Output an array of interfaces print_r($interfaces);
class FileManager implements IteratorAggregate, Countable { // Class code here... } $reflectionClass = new ReflectionClass('FileManager'); $interfaces = $reflectionClass->getInterfaces(); // Check if an interface exists if (in_array('IteratorAggregate', $interfaces)) { echo 'FileManager implements IteratorAggregate interface'; }This example also uses the `getInterfaces()` method to retrieve an array of interfaces implemented by the `FileManager` class. Then, it checks if the class implements the `IteratorAggregate` interface and outputs a message if it does. The package library for this code example could be PHP's built-in Reflection API.