操作系统环境centOS6.5
用yum安装
php的扩展程序
php-pecl-apc-devel.x86_64
perl 兼容的正规表达式库
pcre-devel.x86_64
执行
pecl install SPL_Types
php.ini里面添加一行
extension=spl_types.so
重启
service httpd restart
使用方法
定义枚举类型继承自继承自SplEnum即可
如下:
class Month extends SplEnum{
const __default = self::January;
const January = 1;
const February = 2;
const March = 3;
const April = 4;
const May = 5;
const June = 6;
const July = 7;
const August = 8;
const September = 9;
const October = 10;
const November = 11;
const December = 12;
}
echo new Month(Month::June) ;