is_subclass_of

PHP 4, PHP 5, PHP 7, PHP 8
is_subclass_of - Checks if the object has this class as one of its parents or implements it
Manual
Code Examples

is_subclass_of( mixed$object_or_class, string$class, [bool$allow_string = true] ): bool

Checks if the given object_or_class has the class class as one of its parents or implements it.

Parameters

object_or_class

A class name or an object instance. No error is generated if the class does not exist.

class

The class name

allow_string

If this parameter set to false, string class name as object_or_class is not allowed. This also prevents from calling autoloader if the class doesn't exist.

Return Values

This function returns true if the object object_or_class, belongs to a class which is a subclass of class, false otherwise.

Notes

Note:

Using this function will use any registered autoloaders if the class is not already known.

Related Functions

Example of is_subclass_of

Show all examples for is_subclass_of

PHP Version:


Function is_subclass_of:

Class/Object Information Functions

Most used PHP functions