PHP instanceof
is an operator.
instanceof
returns true if the object on the lefthand side is of the same
class, or a descendant of, the class given on the righthand side.
You can also use the instanceof keyword to check whether an object implements an interface.
PHP instanceof has the syntax of.
$varaibleName instanceof ClassName
For example, given the code &aBook = new ComputerBook;.
<?PHP
class Person {
}
$bill = new Person();
if ($bill instanceof Person) {
print("Is a person");
}
?>
The code above generates the following result.