array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'uk', ), 'this' => array ( 0 => 'function.enum-exists.php', 1 => 'enum_exists', 2 => 'Checks if the enum has been defined', ), 'up' => array ( 0 => 'ref.classobj.php', 1 => 'Функції Класів чи Об\'єктів', ), 'prev' => array ( 0 => 'function.class-exists.php', 1 => 'class_exists', ), 'next' => array ( 0 => 'function.get-called-class.php', 1 => 'get_called_class', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/classobj/functions/enum-exists.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(PHP 8 >= 8.1.0)
enum_exists — Checks if the enum has been defined
This function checks whether or not the given enum has been defined.
enumThe enum name. The name is matched in a case-insensitive manner.
autoloadWhether to autoload if not already loaded.
Приклад #1 enum_exists() example
<?php
// Check that the enum exists before trying to use it
if (enum_exists(Suit::class)) {
$myclass = Suit::Hearts;
}
?>