Copyright © tutorialspoint.com

PHP Function is_a()

previous
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.

Paramters

ParameterDescription
objectRequired. The tested object
classRequired. The class name.

Return Value

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
class WidgetFactory
{
  var $oink = 'moo';
}

// create a new object
$WF = new WidgetFactory();

if (is_a($WF, 'WidgetFactory')) {
  echo "yes, \$WF is still a WidgetFactory";
}
?> 

It will produce following result:

yes, $WF is still a WidgetFactory
previous

Copyright © tutorialspoint.com