get_parent_class
Description
The get_parent_class of Class / Object for PHP retrieves the parent class name for object or class.
Syntax
get_parent_class( object|string $object_or_class = ? ): string|false
Parameters
object_or_class
The tested object or class name. This parameter is optional if called from the object's method.
Return
Returns the name of the parent class of the class of which object_or_class is an instance or the name.
Note: If the object does not have a parent or the class given does not exist false will be returned.
If called without parameter outside object, this function returns false.
Examples
1 · void · internal call
<? class myparentclass { } class mychildclass extends myparentclass { function __construct() { $return = get_parent_class(); echo $return; } } new mychildclass();
myparentclass
2 · object_or_class · external call
<? class myparentclass { } class mychildclass extends myparentclass { } $object_or_class = new mychildclass(); $return = get_parent_class($object_or_class); echo $return;
myparentclass