Click Upvote Click Upvote - 10 months ago 71
PHP Question

How to implement Enum like functionality in PHP?

How can Enum-like functionality (as provided in Java and other high level languages) be used in PHP? I know PHP doesn't allow you to create enums currently, but what's the closest one could get?

Answer Source

Using const, perhaps.

class SomeClass {
    const FIRSTVAL = 1;
    const SECONDVAL = 2;