(PECL spl_types >= 0.1.0)
SplEnum::__construct — Constructs an enumeger object type
This constructor is used to set the value and the strictness of the "Enum" Object.
The input parameter accepts an integer and will throw an UnexpectedValueException if anything else is passed.
A boolean variable to indicate wether the object's strictness should be set or not.
값을 반환하지 않습니다.
Example #1 SplEnum::__construct() example
<?php
class EnumOne extends SplEnum
{
const __default = 1;
}
class EnumTwo extends SplEnum
{
const __default = 2;
}
class EnumThree extends SplEnum
{
const __default = 3;
}
$enumOne = new EnumOne();
$enumTwo = new EnumTwo();
$enumThree = new EnumThree();
echo 'Enum one : ' . $enumOne . PHP_EOL;
echo 'Enum two : ' . $enumTwo . PHP_EOL;
echo 'Enum three: ' . $enumThree . PHP_EOL;
?>
위 예제의 출력:
Enum one : 1 Enum two : 2 Enum three: 3