I am working on a medium sized portal. As I have been working on it I noticed that I am often having to send the same message to users again and again, eg 'You must login to view this page' or 'You do not have sufficient permissions to view this page' I an effort to be consistent I think it is time to store these messages in some kind of variable so that they are always the same every where.
My question to the community is what is the best way to do that.
The two alternatives I have come up with are:
1) define a bunch of constants i.e.
define('MUST_LOGIN', 'You must login to view this page');
2) use a global array i.e.
global $gStd_errors;
$gStd_errors = array('MUST_LOGIN'=>'You must login to view this page');
I like the define style because it is less cumbersome, in my opinion, than referencing a giant array, and may be faster depending on how large the array gets over time. I dislike this method because it clutters the already messy name space, and as time goes on I could end up with many, many of these constants. Advantages of using the array include, that I would be able at any time to see all the error I have defined.
At any rate I'm interested to see what you all think and what you've done on your own projects.
thanks
-Matthew