PHP is_subclass_of() Function Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report The is_subclass_of() function is an inbuilt function in PHP that checks whether the object inherits from or implements the specified class. Syntax: bool is_subclass_of( mixed $object_or_class, string $class, bool $allow_string = true )Parameters: This function accept three parameters that are described below: $object or class: Either a class name or an object instance can be specified, and if the specified class does not exist, no error will be generated.$class: This parameter specifies the class name in a string format.$allow_string: The string class name or object can't be used if this parameter is set to false. If the class doesn't exist, then this parameter prevents from calling the autoloader.Return Value: If the object or class belongs to the parent class, this function will return "true"; otherwise, it will return "false". Example 1: This example demonstrates the PHP is_subclass_of() function. PHP <?php class GeeksforGeek { var $color = "Red"; } class Articles extends GeeksforGeek { var $user = 'Test'; } $ob = new GeeksforGeek(); $article = new Articles(); if (is_subclass_of($article, 'GeeksforGeek')) { echo "Yes, Article is subclass of GeeksforGeek"; } else { echo "No, Articles is not subclass of GeeksforGeek"; } ?> Output: Yes, Article is subclass of GeeksforGeek Example 2: The following code demonstrates another example of the PHP is_subclass_of() method. PHP <?php interface GeeksforGeek { public function hello(); } class Articles implements GeeksforGeek { function hello() { echo "Hey GeeksforGeeks"; } } $ob = new Articles; if (is_subclass_of($ob, 'GeeksforGeek')) { echo "Yes, Articles implements GeeksforGeek interface\n"; } else { echo "No, Articles do not implement GeeksforGeek interface\n"; } if (is_subclass_of($ob, 'Network')) { echo "Yes, Articles implements Network interface"; } else { echo "No, Articles do not implement Network interface"; } ?> Output: Yes, Articles is implement GeeksforGeek interface No, Articles do not implement Network interface Reference: https://www.php.net/manual/en/function.is-subclass-of.php Comment More infoAdvertise with us Next Article PHP is_subclass_of() Function N neeraj3304 Follow Improve Article Tags : PHP PHP-function PHP-Classes/Object-Functions Similar Reads PHP | ReflectionClass isFinal() Function The ReflectionClass::isFinal() function is an inbuilt function in PHP which is used to check the specified class is final or not. Syntax: bool ReflectionClass::isFinal( void ) Parameters: This function does not accept any parameters. Return Value: This function returns true for the success or false 1 min read PHP | is_object() Function The is_object() function is an inbuilt function in PHP which is used to check whether the given value is an object or not. Syntax: bool is_object( mixed $var ) Parameters: This function accepts single parameter as mentioned above and described below: $var: It contains the value of variable that need 1 min read PHP | ReflectionClass isSubclassOf() Function The ReflectionClass::isSubclassOf() function is an inbuilt function in PHP which is used to check if any subclass is available or not. Syntax: bool ReflectionClass::isSubclassOf( $class ) Parameters: This function accepts a single parameter class which is the class name being checked against. Return 1 min read PHP | is_a() function The is_a() is a built-in function in PHP and is used to check whether a given object is of a given class or not. It also checks if the given class is one of the parents of the given object or not. Syntax: boolean is_a($object, $class) Parameters: This function accepts two parameters as shown in the 2 min read PHP | ReflectionClass isCloneable() Function The ReflectionClass::isCloneable() function is an inbuilt function in PHP which is used to check the specified class is cloneable or not. Syntax: bool ReflectionClass::isCloneable( void ) Parameters: This function does not accept any parameters. Return Value: This function returns True if class is c 1 min read Like