(PHP 8 >= 8.1.0)
ReflectionEnum::isBacked — 确定枚举是否为支持枚举
此函数没有参数。
示例 #1 ReflectionEnum::isBacked() 示例
<?php
enum Suit
{
case Hearts;
case Diamonds;
case Clubs;
case Spades;
}
enum BackedSuit: string
{
case Hearts = 'H';
case Diamonds = 'D';
case Clubs = 'C';
case Spades = 'S';
}
var_dump((new ReflectionEnum(Suit::class))->isBacked());
var_dump((new ReflectionEnum(BackedSuit::class))->isBacked());
?>
上面的示例将输出
bool(false) bool(true)