Click Upvote Click Upvote - 1 year ago 116
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;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download