Basic Enums
Enums represent a fixed set of possible values.
They were introduced in PHP 8.1.
Example
Section titled “Example”enum OrderStatus {case Pending;case Shipped;case Delivered;}Using enums
Section titled “Using enums”$status = OrderStatus::Pending;
if ($status === OrderStatus::Pending) {echo "Order not shipped yet";}Listing cases
Section titled “Listing cases”foreach (OrderStatus::cases() as $case) {echo $case->name . PHP_EOL;}