PHP.nl

enum_exists

enum_exists

Checks if the enum has been defined

bool **enum_exists** string $enum bool $autoload

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

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

autoload Whether to if not already loaded. autoload

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

Voorbeeld: example

<?php
// Check that the enum exists before trying to use it
if (enum_exists(Suit::class)) {
    $myclass = Suit::Hearts;
}
?>

function_exists``class_exists``interface_exists``get_declared_classes