What is the best practice for checking if a class implements an interface without using class_implements in PHP?

When checking if a class implements an interface in PHP without using the class_implements function, you can use the instanceof operator to check if an object is an instance of a specific class that implements the interface. This can be achieved by creating an instance of the class and then checking if it is an instance of the interface.

interface MyInterface {
    public function myMethod();
}

class MyClass implements MyInterface {
    public function myMethod() {
        // implementation
    }
}

$myClass = new MyClass();

if ($myClass instanceof MyInterface) {
    echo 'MyClass implements MyInterface';
} else {
    echo 'MyClass does not implement MyInterface';
}