PHP class_parents() Function Last Updated : 28 Mar, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The class_parents() function is an inbuilt function in PHP where the parent class for the given class will be returned. Syntax: class_parents( object|string $object_or_class, bool $autoload = true ): array|false Parameters: This function accepts two parameters that are described below: object_or_class: This parameter specifies the object(i.e. a class instance) or a string that has the class name.autoload: This parameter, by default, defines & calls the __autoload Return Value: If the function is successful then it will return an array otherwise it will return "false". Example 1: The code demonstrates the class_parents() functions PHP <?php class GFG {} class Article extends GFG{} { print_r(class_parents(new Article)); } ?> OutputArray ( [GFG] => GFG ) Example 2: The code demonstrates the class_parents() function. PHP <?php class GFG2 {} class Article extends GFG2{} {} $ob = new Article(); print_r(class_parents($ob)); ?> OutputArray ( [GFG2] => GFG2 ) Reference: https://www.php.net/manual/en/function.class-parents.php Comment More infoAdvertise with us Next Article PHP | get_class() Function N neeraj3304 Follow Improve Article Tags : PHP PHP-function PHP-SPL-Functions Similar Reads PHP | get_class() Function The get_class() function is an inbuilt function in PHP which is used to return the class name of an object. Syntax: string get_class( object $object ) Parameters: This function accepts single parameter $object which holds the object that need to be tested. The value of this parameter can be omitted 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 class_uses() Function The class_uses() function is an inbuilt function in PHP where the traits utilized by the given class, will be returned. Syntax: class_uses($object_or_class,$autoload = true): array|false Parameters: This function accepts the two parameters that are described below object_or_class: The name of the cl 2 min read PHP | is_callable() Function The is_callable() function is an inbuilt function in PHP which is used to verify the contents of a variable can be called as a function. It can check that a simple variable contains the name of a valid function, or that an array contains a properly encoded object and function name. Syntax: bool is_c 2 min read PHP | parse_url() Function The parse_url() function is an inbuilt function in PHP which is used to return the components of a URL by parsing it. It parses an URL and return an associative array which contains its various components. Syntax: parse_url( $url, $component = -1 ) Parameters: This function accepts two parameters as 2 min read PHP | opendir() Function The opendir() function in PHP is an inbuilt function which is used to open a directory handle. The path of the directory to be opened is sent as a parameter to the opendir() function and it returns a directory handle resource on success, or FALSE on failure. The opendir() function is used to open up 2 min read Like