enum_exists
(PHP 8 >= 8.1.0)
enum_exists — Checks if the enum has been defined
Description
This function checks whether or not the given enum has been defined.
Parameters
enumThe enum name. The name is matched in a case-insensitive manner.
autoloadWhether to autoload if not already loaded.
Examples
Example #1 enum_exists() example
<?php
// Check that the enum exists before trying to use it
if (enum_exists(Suit::class)) {
$myclass = Suit::Hearts;
}
?>See Also
- function_exists() - Return true if the given function has been defined
- class_exists() - Checks if the class has been defined
- interface_exists() - Checks if the interface has been defined
- get_declared_classes() - Returns an array with the name of the defined classes
↑ and ↓ to navigate • Enter to select • Esc to close • / to open