jsjohnst / php_class_lib

A collection of PHP classes which anyone can add to their development toolbox

This URL has Read+Write access

php_class_lib / classes / types / enum / example2.php
100644 27 lines (21 sloc) 0.661 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
 
include("Enum.inc");
include("EnumIterator.inc");
 
Enum::enablePureMode();
 
abstract class Months extends Enum {}
 
class JANUARY extends Months { var $value = 1; }
class FEBRUARY extends Months {}
class MARCH extends Months {}
class APRIL extends Months {}
class MAY extends Months {}
class JUNE extends Months {}
class JULY extends Months {}
class AUGUST extends Months {}
class SEPTEMBER extends Months {}
class OCTOBER extends Months {}
class NOVEMBER extends Months {}
class DECEMBER extends Months {}
 
echo "Months of the year:\n";
foreach(Enum::iterator("Months") as $member) {
echo "\t" . $member . " has value " . (Enum::get($member)) . "\n";
}