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";
}
}
}
?>
Related examples in the same category