is_a
is_a
Checks whether the object is of a given type or subtype
bool **is_a** mixed $object_or_class string $class bool $allow_string
Determines if the given is the
object type,
or has as one of its supertypes.
object_or_class``class``class
object_or_classA class name or an object instance.
classThe class or interface name
allow_string
If this parameter set to false, string class name as
is not allowed. This also prevents from calling autoloader if the class doesn't exist.
object_or_class
Returns true if is the
object type,
or has as one of its supertypes, false otherwise.
object_or_class``class``class
Voorbeeld: example
<?php
// define a class
class WidgetFactory
{
var $oink = 'moo';
}
// create a new object
$WF = new WidgetFactory();
if (is_a($WF, 'WidgetFactory')) {
echo "yes, \$WF is still a WidgetFactory\n";
}
?>
Voorbeeld: Using the operator
<?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';
}
?>
get_class``get_parent_class``is_subclass_of