Given a class instance, is it possible to determine if it implements a particular interface? As far as I know, there isn’t a built-in function to do this directly. What options do I have (if any)?
Given a class instance, is it possible to determine if it implements a particular
Share
You can use the "instanceof" operator. To use it, the left operand is a class instance and the right operand is an interface. It returns true if the object implements a particular interface.
Reference: https://www.php.net/manual/en/language.operators.type.php#example-124