class MyInterface { // interface methods definition } class MyClass { // class methods definition } $interface = new ReflectionClass('MyInterface'); $class = new ReflectionClass('MyClass'); echo $interface->isInterface(); // true echo $class->isInterface(); // false
interface MyInterface { // interface methods definition } class MyClass implements MyInterface { // class methods definition } $class = new ReflectionClass('MyClass'); echo $class->isInterface(); // false echo $class->implementsInterface('MyInterface'); // trueIn this example, we define an interface MyInterface and a class MyClass which implements it. We create a reflection class for MyClass and then use the isInterface method to check if it is an interface or not. The output will be false because MyClass is not an interface. We also use the implementsInterface method to check if MyClass implements the MyInterface interface. The output will be true because MyClass implements the MyInterface interface. Package Library: This code example probably belongs to a library/framework that uses interfaces to provide a contract for its classes to implement.