Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

class_exists() With Enums

<?php


enum MyEnum {}

class_exists(MyEnum::class); // true or false?

In PHP, there are dedicated functions to check the availability of structures:

  • class_exists()

  • trait_exists()

  • interface_exists()

  • enum_exists()

What would the code here produce?

This is displaying true. Enumerations are considered as classes, even as they have specific limitations and behavior, compared to normal classes.

See Also

PHP Features

Last updated: 10 September 2026