Hello,
I have a little question.
I would like to know how to check if an object is compliant with an interface.
I know that if the Class implements explicitly the Interface, like this:
the operator instanceof will let me know. like this:
However in my case the Class does not implement the interface explicitly.
so my only goal is to know if $bobmarley has some methods i need from it.
Lets say my interface is like this:
I want to be able to know if $bobMarley has such a method in his class. And so i could call:
Do you know how to do this?
Regards
Bilibytes
I have a little question.
I would like to know how to check if an object is compliant with an interface.
I know that if the Class implements explicitly the Interface, like this:
Code:
Class RobertNestaMarley implements Smoker_Interface
Code:
$bobMarley = new RobertNestaMarley()
if ($bobMarley instanceof Smoker_Interface) {
echo 'Bob likes to smoke';
}
so my only goal is to know if $bobmarley has some methods i need from it.
Lets say my interface is like this:
Code:
Interface Smoker_Interface
{
public function lightACigar($brand);
}
Code:
$bobMarley->lightACigar('Cohiba');
Do you know how to do this?
Regards
Bilibytes
Comment