Deprecated: Optional parameter $keys declared before required parameter $cms_id is implicitly treated as a required parameter in /home/www/dev/work/class/blog/CmsKey.php on line 75

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$title is deprecated in /home/www/dev/work/website/lvesu/class/controller/blog/php.php on line 28

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$outlink is deprecated in /home/www/dev/work/website/lvesu/template/blog/cms/php.manual.tpl on line 2

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$status is deprecated in /home/www/dev/work/website/lvesu/template/blog/index.head.php on line 2
PHP - Manual: ReflectionEnum::getBackingType - 互联网笔记

略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: ReflectionEnum::getBackingType

2025-06-02

ReflectionEnum::getBackingType

(PHP 8 >= 8.1.0)

ReflectionEnum::getBackingType获取枚举回退的类型

说明

public ReflectionEnum::getBackingType(): ?ReflectionNamedType

如果一个枚举是回退枚举,该方法会根据枚举回退的类型, 返回 ReflectionType 的实例。 如果不是个回退枚举,会返回 null

参数

此函数没有参数。

返回值

ReflectionNamedType 的实例。 如果 Enum 没有回退的类型时,返回 null

更新日志

版本 说明
8.2.0 返回类型现在声明为 ?ReflectionNamedType。之前声明为 ?ReflectionType

示例

示例 #1 ReflectionEnum::getBackingType() 示例

<?php
enum Suit: string
{
case
Hearts = 'H';
case
Diamonds = 'D';
case
Clubs = 'C';
case
Spades = 'S';
}

$rEnum = new ReflectionEnum(Suit::class);

$rBackingType = $rEnum->getBackingType();

var_dump((string) $rBackingType);
?>

以上示例会输出:

string(6) "string"

参见

添加备注

用户贡献的备注

此页面尚无用户贡献的备注。

官方地址:https://www.php.net/manual/en/reflectionenum.getbackingtype.php

冷却塔厂家 广告
中文GPT4.0无需注册 广告
北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3