PHP/Language Basics/instanceof
Difference between instanceof and is_subclass_of( )
<?
class Dog { }
class Poodle extends Dog { }
$poppy = new Poodle( );
print (int)($poppy instanceof Poodle);
print "\n";
print (int)is_subclass_of($poppy, "Poodle");
?>
Using the instanceof Operator
<?php
class Math {
public function add($op1, $op2) {
if(($op1 instanceof Float) && ($op2 instanceof Float)) {
return $op1->getFloat() + $op2->getFloat();
} else {
echo "Must pass two Floats!\n";
}
}
}
?>