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

Typed By Enum

<?php

enum e {
    case A;
    
    const B = 1;
}

var_dump(e::A instanceof e);
var_dump(e::B instanceof e);

?>

Enumeration cannot be instantiated into an object. In fact, the cases of the enumeration are the objects. Hence, a case object has the enumeration type.

Then, an enumeration (class) constant cannot be confused with a case, because the enumeration cannot be instantiated, and class constants also do not support new initializers.

See Also

PHP Features

Last updated: 10 September 2026