|
Posted by Ewoud Dronkert on 11/07/05 11:40
Oli Filth wrote:
> Seamus M said the following on 06/11/2005 22:40:
>> I can't find any info on enumerations in the PHP manual
>
> 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"
Or an associative array perhaps?
$allitems = array('cat' => 1, 'dog' => 2, 'fish' => 3);
echo $allitems['cat'];
Or constants, but they are not restricted to one type or container:
define('ALL_CAT', 1);
define('ALL_DOG', 2);
define('ALL_FISH', 3);
echo ALL_CAT;
--
E. Dronkert
Navigation:
[Reply to this message]
|