Documentation for Ice 3.4. The latest release is Ice 3.7. Refer to the space directory for other releases.

PHP does not have an enumerated type, so a Slice enumeration is mapped to a PHP class: the name of the Slice enumeration becomes the name of the PHP class; for each enumerator, the class contains a constant with the same name as the enumerator. For example:

Slice
enum Fruit { Apple, Pear, Orange };

The generated PHP class looks as follows:

PHP
class Fruit
{
    const Apple = 0;
    const Pear = 1;
    const Orange = 2;
}

Since enumerated values are mapped to integers, application code is not required to use the generated constants. When an enumerated value enters the Ice run time, Ice validates that the given integer is within the expected range for the enumeration. However, to minimize the potential for defects in your code, we recommend using the generated constants instead of literal integers.

See Also
  • No labels