Learning PHP
Advanced PHP
PHP Function Reference
PHP Useful Resources
Selected Reading
© 2011 TutorialsPoint.COM
|
PHP Function is_a()
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
Parameter | Description |
object | Required. The tested object |
class | Required. 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
|
|
|
|