Enumeration’s Cases Comparisons¶
<?php
enum A: string
{
case Foo = 'bar';
}
enum B: string
{
case Foo = 'bar';
}
echo A::Foo === B::Foo ? 'Yes' : 'No';
Enumeration cases are different when the enumeration are different, not when the value of the case is different. It is a difference with using constants for enumerations.
To compare their value, the comparison must be done with the ‘value’ property, not the object.
See Also¶
PHP Features¶
Last updated: 14 July 2026