ReflectionClass::getParentClass

(PHP 5, PHP 7, PHP 8)

ReflectionClass::getParentClass親クラスを取得する

説明

public ReflectionClass::getParentClass(): ReflectionClass|false

親クラスを取得します。

パラメータ

この関数にはパラメータはありません。

戻り値

ReflectionClass を返します。 親が存在しない場合は、false を返します。

参考

add a note

User Contributed Notes 1 note

up
18
isaac dot z dot foster at gmail dot com
12 years ago
To find all parents of a class you can use the following code:

        $class = new ReflectionClass('classname');
        
        $parents = [];
        
        while ($parent = $class->getParentClass()) {
            $parents[] = $parent->getName();
            $class = $parent;
        }
        
        echo "Parents: " . implode(", ", $parents);
To Top