(PHP 8 >= 8.1.0)
enum_exists — 列挙型が定義されているかを調べる
$enum, bool $autoload = true): boolこの関数は、指定された列挙型が定義されているかを調べます。
enum が定義済みの列挙型である場合、
true を返します。そうでない場合、false を返します。
例1 enum_exists() の例
<?php
// Check that the enum exists before trying to use it
if (enum_exists(Suit::class)) {
$myclass = Suit::Hearts;
}
?>