There are many PHP conventions, and they all contradict each other. But I use similar notation, although I like to group constants in a class, so I will have a class Height (or MySquare_Height) that has constants. That way, I can use it as a kind of Enum, as you received in other languages. Especially when you use a backlit editor.
<? abstract class MySquare_Color { const GREEN = 'Green'; const RED = 'Red'; } abstract class MySquare_Height { const SMALL = 100; const MEDIUM = 300; const BIG = 500; }
If you are using PHP 5.3, you can simply name the Color and Height classes and put them in the MySquare namespace:
<?php
source share