A Slice constant maps to a PHP constant. Consider the following definitions:
{zcode:slice} module M { const bool AppendByDefault = true; const byte LowerNibble = 0x0f; const string Advice = "Don't Panic!"; const short TheAnswer = 42; const double PI = 3.1416; enum Fruit { Apple, Pear, Orange }; const Fruit FavoriteFruit = Pear; }; {zcode} |
The mapping for these constants is shown below:
{zcode:php} define('M_AppendByDefault', true); define('M_LowerNibble', 15); define('M_Advice', "Don't Panic!"); define('M_TheAnswer', 42); define('M_PI', 3.1416); define('M_FavoriteFruit', M_Fruit::Pear); {zcode} |
An application refers to a constant using its flattened name:
{zcode:php} $ans = M_TheAnswer; {zcode} |
Using the namespace mapping, Slice constants are mapped to PHP constants in the enclosing namespace:
{zcode:php} $ans = \M\TheAnswer; {zcode} |