Doing a project with more people in php can be really complicated when it comes to naming constants. For some reason each people has his own way of naming things. Some people will like to start constants with an underscore, like _MYCONSTANT and some others will not, like MYCONSTANT.
The problems get stronger when things begin to appear repeatedly (specially if there's more than one programmer adding constants at the same time).
So what I did is try to find a way of naming which was meaningful and more or less consistent. I'll explain you so we can all benefit from the other's experiences...
There are several types of constants, depending on the purpose:
- labels: something which appears with form controls, like "Enter the text here". These constants are prepended with LBL_
- texts: text which appears on any place, but is not a label. These have a TXT_ prepended.
- titles: which are used on page headers and section names: we prepend a TITLE_
and you won't have collisions like MODULE1_INSTRUCTIONS being used both for the title and for the text of the instructions by different programmers.
Also, constants are alphabetically ordered in the files. Not appended at the end with any order...
It could also be applied to more languages. In fact I somehow took some ideas from the way constants worked on MFC or visual basic (taking into account that I don't remember too much from those days so maybe it is not exactly as I thought...).
What do you think of this method? Do you have some suggestion that could make it better?