English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP tutorial

Advanced PHP tutorial

PHP & MySQL

PHP reference manual

PHP is_a() function usage and example

PHP Class/Object function reference manual

Returns TRUE if the object belongs to this class or this class is the parent class of the object

Syntax

is_a($object, $class_name)

Definition and usage

Check if the given object belongs to this class or if this class is one of the parent classes of the object.

Parameter

NumberParameters and descriptions
1

object (required)

Object to be tested

2

class (required)

Class name.

Return value

Returns TRUE if the object belongs to this class or if this class is one of the parent classes of the object, otherwise returns FALSE.

Online examples

Here 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

Online examples

In PHP 5 Using the instanceof operator

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

  PHP Class/Object function reference manual