Enumeration (enum)
Enumerations are a restricting layer on top of classes and class constants, intended to provide a way to define a closed set of possible values for a type.
<?php
enum Suit
{
case Hearts;
case Diamonds;
case Clubs;
case Spades;
}
?>
See Also
- Enumerations in PHP
- 5 Pitfalls of Upgrade to Native PHP Enums and How to Avoid Them
- On the use of enums
- Enum in PHP — Real life examples
Related
- Enumeration Case
- Collection
- Class Interface Trait Enumeration (CITE)
- Backed Enum
- BackedEnum
- Case
- http_build_query()
- Unbacked Enum
- UnitEnum
- Dynamic Class Constant
- Algebraic Data Type
- Compile-time Evaluation
- Sealed Class
- Sum Type