->self[$name];
}
public function add( $name = null, $enum = null ) {
if( isset($enum) )
$this->self[$name] = $enum;
else
$this->self[$name] = end($this->self) + 1;
}
}
class DefinedEnum extends Enum {
public function __construct( $itms ) {
foreach( $itms as $name => $enum )
$this->add($name, $enum);
}
}
class FlagsEnum extends Enum {
public function __construct( ) {
$args = func_get_args();
for( $i=0, $n=count($args), $f=0x1; $i<$n; $i++, $f *= 0x2 )
$this->add($args[$i], $f);
}
}
?>
Example usage:
<?php
$eFruits = new Enum("APPLE", "ORANGE"
3/10 首页 上一页 1 2 3 4 5 6 下一页 尾页 |