PHP 8 · Types and functions

Define an enum

A fixed set of named values, optionally backed by strings or integers.

enum Status: string
{
    case Draft = 'draft';
    case Published = 'published';
}

$status = Status::from('draft');

Official PHP 8 documentation

More types and functions commands

All types and functions commands · PHP 8 cheatsheet

Was this page helpful?