爱程序网

PHP的Enum(枚举)的实现

来源: 阅读:

转载请保留原文地址:http://www.cnblogs.com/zsxfbj/p/php_enum.html

PHP其实有Enum类库的,需要安装perl扩展,所以不是php的标准扩展,因此代码的实现需要运行的php环境支持。

(1)扩展类库SplEnum类。该类的摘要如下:

SplEnum extends SplType {/* Constants */const NULL __default = null ;/* 方法 */public array getConstList ([ bool $include_default = false ] )/* 继承的方法 */SplType::__construct ([ mixed $initial_value [, bool $strict ]] )}