目次
クラス内に定数を定義してEnumのように使用する
コード
class TestEnum
{
const January = 1;
const February = 2;
const March = 3;
const April = 4;
const May = 5;
const Jun = 6;
const July = 7;
const August = 8;
const September = 9;
const October = 10;
const November = 11;
const December = 12;
}
echo TestEnum::February . PHP_EOL;
echo TestEnum::December . PHP_EOL;
実行結果
2
12
[A8_TechAcademy065]
[Footer]