略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: ReflectionClass::getParentClass

2025-02-27

ReflectionClass::getParentClass

(PHP 5, PHP 7, PHP 8)

ReflectionClass::getParentClass获取父类

说明

public ReflectionClass::getParentClass(): ReflectionClass|false

获取父级类。

参数

此函数没有参数。

返回值

ReflectionClass,没有父类为 false

参见

添加备注

用户贡献的备注 1 note

up
18
isaac dot z dot foster at gmail dot com
11 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);

官方地址:https://www.php.net/manual/en/reflectionclass.getparentclass.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3