The enumerated type for PHP

Whenever a procedure accepts a limited set of variables one could use an enumeration. Enumerations make for clearer and more readable code, particularly when meaningful names are used. A page at MSDN states the benefits of using an enumeration include:

reduction of errors caused by transposing or mistyping numbers,

simplify changing values in the future,

code is easier to read, which means it is less likely that errors will creep into it and/or

ensuring forward compatibility. With enumerations, your code is less likely to fail if in the future someone changes the values corresponding to the member names.

Enumerations are a must if your software solution spans across multiple projects and/or if the team you work is rather large.Enumerations are well known in the programming world, except for PHP. This is true while the database used most often with PHP, MySQL, does support Enums. This is why I took the liberty to write an implementation for enums in PHP.