Sunday, 2 October 2011

PHP & Enums

Enums are not native to PHP, at least not for the moment but I found a way to simulate with the help of this post on stackoverflow.

<?php

class DiceEnum
{
        const d4 = 4;
        const d6 = 6;
        const d8 = 8;
        const d10 = 10;
        const d12 = 12;
        const d20 = 20;
}
?>

But if I base myself on the SPL documentation, it’s seems we are going to have a supported native integration very soon.

0 comments: