Check if the object is of this class or has this class as one of its parents in PHP
Description
The following code shows how to check if the object is of this class or has this class as one of its parents.
Example
/*from ww w. j a va 2s . c om*/
<?php
// define a class
class WidgetFactory
{
var $oink = 'moo';
}
// create a new object
$WF = new WidgetFactory();
if ($WF instanceof WidgetFactory) {
echo 'Yes, $WF is a WidgetFactory';
}
?>
The code above generates the following result.