PHP - Function is_a()


Advertisements


Syntax

is_a ( $object, $class_name )

Definition and Usage

Checks if the given object is of this class or has this class as one of its parents.

Parameters

Sr.No Parameter & Description
1

object(Required)

The tested object

2

class(Required)

The class name.

Return Value

It returns TRUE if the object is of this class or has this class as one of its parents, FALSE otherwise.

Example

Following is the usage of this function −

<?php
if ($wid_fact instanceof WidgetFactory) {
    echo 'Yes, $wid_fact is a WidgetFactory';
}
?> 

It will produce the following result −

Yes, $WF is a WidgetFactory

php_function_reference.htm

Advertisements