(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.
enum
The enum name. The name is matched in a case-insensitive manner.
autoload
Whether to autoload if not already loaded.
Example #1 enum_exists() example
<?php
/ Check that the enum exists before trying to use it
if (enum_exists(Suit::class)) {
$myclass = Suit::Hearts;
}
?>
Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!
Check out: eBank.nz (Art Generator) |
Netwrck.com (AI Tools) |
Text-Generator.io (AI API) |
BitBank.nz (Crypto AI) |
ReadingTime (Kids Reading) |
RewordGame |
BigMultiplayerChess |
WebFiddle |
How.nz |
Helix AI Assistant