|
Posted by Oli Filth on 11/07/05 03:16
Seamus M said the following on 06/11/2005 22:40:
> I can't find any info on enumerations in the PHP manual, so I assume there
> is no built in way to create them. Can anyone tell me the best way to build
> a simple enumeration, such as:
>
> Enum AllItems as Integer
>
> 'First Item' = 1;
> 'Second Item' = 2;
> :
> End Enum
>
PHP does not have enumerations per se.
I guess the closest thing you could do (assuming PHP 5) is an abstract
class with constants, e.g.:
abstract class AllItems
{
const Dog = 1;
const Cat = 2;
const Ocelot = 3;
}
echo AllItems::Dog; // displays "1"
--
Oli
Navigation:
[Reply to this message]
|