Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<class_existsget_called_class>
^Classes/Object FunctionsLast updated: Mon, 26 Oct 2026

enum_exists

(PHP 8 >= 8.1.0)

enum_exists — Checks if the enum has been defined

Description

function enum_exists(string $enum, bool $autoload = true): bool

This function checks whether or not the given enum has been defined.

Parameters

enum

The enum name. The name is matched in a case-insensitive manner.

autoload

Whether to autoload if not already loaded.

Return Values

Returns true if enum is a defined enum, false otherwise.

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


<class_existsget_called_class>
^Classes/Object FunctionsLast updated: Mon, 26 Oct 2026