ReflectionEnum::hasCase
(PHP 8 >= 8.1.0)
ReflectionEnum::hasCase — 在枚举上检测条目
参数
name
-
要检测的条目。
示例
示例 #1 ReflectionEnum::hasCase() 示例
<?php
enum Suit
{
case Hearts;
case Diamonds;
case Clubs;
case Spades;
}
$rEnum = new ReflectionEnum(Suit::class);
var_dump($rEnum->hasCase('Hearts'));
var_dump($rEnum->hasCase('Horseshoes'));
?>
以上示例会输出:
bool(true) bool(false)
+添加备注
用户贡献的备注
此页面尚无用户贡献的备注。
备份地址:http://www.lvesu.com/blog/php/reflectionenum.hascase.php